Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,62 +1,42 @@
|
|
| 1 |
-
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
| 2 |
-
|
| 3 |
-
# %% auto 0
|
| 4 |
-
__all__ = ['columns_to_click', 'title', 'description', 'dtypes', 'get_data']
|
| 5 |
-
|
| 6 |
-
# %% app.ipynb 0
|
| 7 |
import gradio as gr
|
| 8 |
import pandas as pd
|
| 9 |
|
| 10 |
-
|
| 11 |
-
# %% app.ipynb 1
|
| 12 |
columns_to_click = ["Paper / Repo", "Playground"]
|
| 13 |
|
| 14 |
def get_data():
|
|
|
|
| 15 |
df = pd.read_csv(
|
| 16 |
"https://docs.google.com/spreadsheets/d/e/2PACX-1vSC40sszorOjHfozmNqJT9lFiJhG94u3fbr3Ss_7fzcU3xqqJQuW1Ie_SNcWEB-uIsBi9NBUK7-ddet/pub?output=csv",
|
| 17 |
skiprows=1,
|
| 18 |
)
|
| 19 |
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
df = df.copy()[~df["Model"].isna()]
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# %% app.ipynb 3
|
| 27 |
-
# Drop TBA models
|
| 28 |
-
df = df.copy()[df["Parameters \n(B)"] != "TBA"]
|
| 29 |
-
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
def make_clickable_cell(cell):
|
| 33 |
-
if pd.isnull(cell):
|
| 34 |
-
return ""
|
| 35 |
-
else:
|
| 36 |
-
return f'<a target="_blank" href="{cell}">{cell}</a>'
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# %% app.ipynb 7
|
| 40 |
for col in columns_to_click:
|
| 41 |
df[col] = df[col].apply(make_clickable_cell)
|
| 42 |
|
| 43 |
return df
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
"""
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
# %% app.ipynb 3
|
| 53 |
-
dtypes = ["str" if c not in columns_to_click else "markdown" for c in get_data().columns]
|
| 54 |
-
|
| 55 |
|
| 56 |
-
#
|
| 57 |
with gr.Blocks() as demo:
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
gr.DataFrame(get_data, datatype=dtypes, every=60)
|
| 61 |
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
+
# Assuming columns_to_click are the columns which contain URLs that you want to make clickable
|
|
|
|
| 5 |
columns_to_click = ["Paper / Repo", "Playground"]
|
| 6 |
|
| 7 |
def get_data():
|
| 8 |
+
# Load the CSV file into a DataFrame
|
| 9 |
df = pd.read_csv(
|
| 10 |
"https://docs.google.com/spreadsheets/d/e/2PACX-1vSC40sszorOjHfozmNqJT9lFiJhG94u3fbr3Ss_7fzcU3xqqJQuW1Ie_SNcWEB-uIsBi9NBUK7-ddet/pub?output=csv",
|
| 11 |
skiprows=1,
|
| 12 |
)
|
| 13 |
|
| 14 |
+
# Drop rows where the 'Model' column is NaN
|
| 15 |
+
df.dropna(subset=['Model'], inplace=True)
|
| 16 |
|
| 17 |
+
# Drop rows where the 'Parameters \n(B)' column is 'TBA'
|
| 18 |
+
df = df[df["Parameters \n(B)"] != "TBA"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
# Apply make_clickable_cell to the specified columns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
for col in columns_to_click:
|
| 22 |
df[col] = df[col].apply(make_clickable_cell)
|
| 23 |
|
| 24 |
return df
|
| 25 |
|
| 26 |
+
def make_clickable_cell(cell):
|
| 27 |
+
if pd.isnull(cell) or not isinstance(cell, str):
|
| 28 |
+
return ""
|
| 29 |
+
else:
|
| 30 |
+
return f'<a target="_blank" href="{cell}">{cell}</a>'
|
| 31 |
|
| 32 |
+
# Load the data to get the columns for setting up datatype
|
| 33 |
+
dataframe = get_data()
|
| 34 |
+
dtypes = ["str" if c not in columns_to_click else "html" for c in dataframe.columns]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
# Gradio app setup
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
+
# Markdown and DataFrame components
|
| 39 |
+
...
|
|
|
|
| 40 |
|
| 41 |
+
# Launch the Gradio app
|
| 42 |
+
demo.launch()
|