Spaces:
Running
Running
Fix
Browse files
app.ipynb
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
"metadata": {},
|
| 8 |
"outputs": [],
|
| 9 |
"source": [
|
| 10 |
-
"
|
| 11 |
"import gradio as gr\n",
|
| 12 |
"import pandas as pd\n",
|
| 13 |
"from huggingface_hub import list_models"
|
|
@@ -20,7 +20,7 @@
|
|
| 20 |
"metadata": {},
|
| 21 |
"outputs": [],
|
| 22 |
"source": [
|
| 23 |
-
"
|
| 24 |
"def get_submissions(category):\n",
|
| 25 |
" submissions = list_models(filter=[\"dreambooth-hackathon\", category], full=True)\n",
|
| 26 |
" leaderboard_models = []\n",
|
|
@@ -86,7 +86,7 @@
|
|
| 86 |
}
|
| 87 |
],
|
| 88 |
"source": [
|
| 89 |
-
"
|
| 90 |
"block = gr.Blocks()\n",
|
| 91 |
"\n",
|
| 92 |
"with block:\n",
|
|
|
|
| 7 |
"metadata": {},
|
| 8 |
"outputs": [],
|
| 9 |
"source": [
|
| 10 |
+
"#|export\n",
|
| 11 |
"import gradio as gr\n",
|
| 12 |
"import pandas as pd\n",
|
| 13 |
"from huggingface_hub import list_models"
|
|
|
|
| 20 |
"metadata": {},
|
| 21 |
"outputs": [],
|
| 22 |
"source": [
|
| 23 |
+
"#|export\n",
|
| 24 |
"def get_submissions(category):\n",
|
| 25 |
" submissions = list_models(filter=[\"dreambooth-hackathon\", category], full=True)\n",
|
| 26 |
" leaderboard_models = []\n",
|
|
|
|
| 86 |
}
|
| 87 |
],
|
| 88 |
"source": [
|
| 89 |
+
"#|export\n",
|
| 90 |
"block = gr.Blocks()\n",
|
| 91 |
"\n",
|
| 92 |
"with block:\n",
|
app.py
CHANGED
|
@@ -1,9 +1,87 @@
|
|
| 1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
| 2 |
|
| 3 |
# %% auto 0
|
| 4 |
-
__all__ = []
|
| 5 |
|
| 6 |
# %% app.ipynb 0
|
| 7 |
import gradio as gr
|
| 8 |
import pandas as pd
|
| 9 |
from huggingface_hub import list_models
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
| 2 |
|
| 3 |
# %% auto 0
|
| 4 |
+
__all__ = ['block', 'get_submissions']
|
| 5 |
|
| 6 |
# %% app.ipynb 0
|
| 7 |
import gradio as gr
|
| 8 |
import pandas as pd
|
| 9 |
from huggingface_hub import list_models
|
| 10 |
+
|
| 11 |
+
# %% app.ipynb 1
|
| 12 |
+
def get_submissions(category):
|
| 13 |
+
submissions = list_models(filter=["dreambooth-hackathon", category], full=True)
|
| 14 |
+
leaderboard_models = []
|
| 15 |
+
|
| 16 |
+
for submission in submissions:
|
| 17 |
+
# user, model, likes
|
| 18 |
+
leaderboard_models.append(
|
| 19 |
+
(
|
| 20 |
+
submission.id.split("/")[0],
|
| 21 |
+
submission.id.split("/")[-1],
|
| 22 |
+
submission.likes,
|
| 23 |
+
)
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
df = pd.DataFrame(data=leaderboard_models, columns=["User", "Model", "Likes"])
|
| 27 |
+
df.sort_values(by=["Likes"], ascending=False, inplace=True)
|
| 28 |
+
df.insert(0, "Rank", list(range(1, len(df) + 1)))
|
| 29 |
+
return df
|
| 30 |
+
|
| 31 |
+
# %% app.ipynb 2
|
| 32 |
+
block = gr.Blocks()
|
| 33 |
+
|
| 34 |
+
with block:
|
| 35 |
+
gr.Markdown("hi")
|
| 36 |
+
with gr.Tabs():
|
| 37 |
+
with gr.TabItem("Animal"):
|
| 38 |
+
with gr.Row():
|
| 39 |
+
animal_data = gr.outputs.Dataframe(type="pandas")
|
| 40 |
+
with gr.Row():
|
| 41 |
+
data_run = gr.Button("Refresh")
|
| 42 |
+
data_run.click(
|
| 43 |
+
get_submissions, inputs=gr.Variable("Animal"), outputs=animal_data
|
| 44 |
+
)
|
| 45 |
+
with gr.TabItem("Science"):
|
| 46 |
+
with gr.Row():
|
| 47 |
+
science_data = gr.outputs.Dataframe(type="pandas")
|
| 48 |
+
with gr.Row():
|
| 49 |
+
data_run = gr.Button("Refresh")
|
| 50 |
+
data_run.click(
|
| 51 |
+
get_submissions, inputs=gr.Variable("Animal"), outputs=science_data
|
| 52 |
+
)
|
| 53 |
+
with gr.TabItem("Food"):
|
| 54 |
+
with gr.Row():
|
| 55 |
+
food_data = gr.outputs.Dataframe(type="pandas")
|
| 56 |
+
with gr.Row():
|
| 57 |
+
data_run = gr.Button("Refresh")
|
| 58 |
+
data_run.click(
|
| 59 |
+
get_submissions, inputs=gr.Variable("Food"), outputs=food_data
|
| 60 |
+
)
|
| 61 |
+
with gr.TabItem("Landscape"):
|
| 62 |
+
with gr.Row():
|
| 63 |
+
landscape_data = gr.outputs.Dataframe(type="pandas")
|
| 64 |
+
with gr.Row():
|
| 65 |
+
data_run = gr.Button("Refresh")
|
| 66 |
+
data_run.click(
|
| 67 |
+
get_submissions, inputs=gr.Variable("Landscape"), outputs=data
|
| 68 |
+
)
|
| 69 |
+
with gr.TabItem("Wilcard"):
|
| 70 |
+
with gr.Row():
|
| 71 |
+
wildcard_data = gr.outputs.Dataframe(type="pandas")
|
| 72 |
+
with gr.Row():
|
| 73 |
+
data_run = gr.Button("Refresh")
|
| 74 |
+
data_run.click(
|
| 75 |
+
get_submissions,
|
| 76 |
+
inputs=gr.Variable("Wildcard"),
|
| 77 |
+
outputs=wildcard_data,
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
block.load(get_submissions, inputs=gr.Variable("animal"), outputs=animal_data)
|
| 81 |
+
block.load(get_submissions, inputs=gr.Variable("science"), outputs=science_data)
|
| 82 |
+
block.load(get_submissions, inputs=gr.Variable("food"), outputs=food_data)
|
| 83 |
+
block.load(get_submissions, inputs=gr.Variable("landscape"), outputs=landscape_data)
|
| 84 |
+
block.load(get_submissions, inputs=gr.Variable("wildcard"), outputs=wildcard_data)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
block.launch()
|