Upload with huggingface_hub
Browse files- requirements.txt +1 -1
- run.ipynb +1 -1
- run.py +13 -9
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
plotly
|
2 |
pypistats
|
3 |
-
https://gradio-main-build.s3.amazonaws.com/
|
|
|
1 |
plotly
|
2 |
pypistats
|
3 |
+
https://gradio-main-build.s3.amazonaws.com/0879f0a296604893f195429611b8c7484d81ad0a/gradio-3.14.0-py3-none-any.whl
|
run.ipynb
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: blocks_multiple_event_triggers"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio plotly pypistats"]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import pypistats\n", "from datetime import date\n", "from dateutil.relativedelta import relativedelta\n", "import pandas as pd\n", "\n", "
|
|
|
1 |
+
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: blocks_multiple_event_triggers"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio plotly pypistats"]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import pypistats\n", "from datetime import date\n", "from dateutil.relativedelta import relativedelta\n", "import pandas as pd\n", "\n", "def get_plot(lib, time):\n", " data = pypistats.overall(lib, total=True, format=\"pandas\")\n", " data = data.groupby(\"category\").get_group(\"with_mirrors\").sort_values(\"date\")\n", " start_date = date.today() - relativedelta(months=int(time.split(\" \")[0]))\n", " data = data[(data['date'] > str(start_date))]\n", " data.date = pd.to_datetime(pd.to_datetime(data.date))\n", " return gr.LinePlot.update(value=data, x=\"date\", y=\"downloads\",\n", " tooltip=['date', 'downloads'],\n", " title=f\"Pypi downloads of {lib} over last {time}\",\n", " overlay_point=True,\n", " height=400,\n", " width=900)\n", "\n", "\n", "with gr.Blocks() as demo:\n", " gr.Markdown(\n", " \"\"\"\n", " ## Pypi Download Stats \ud83d\udcc8\n", " See live download stats for all of Hugging Face's open-source libraries \ud83e\udd17\n", " \"\"\")\n", " with gr.Row():\n", " lib = gr.Dropdown([\"transformers\", \"datasets\", \"huggingface-hub\", \"gradio\", \"accelerate\"],\n", " value=\"gradio\", label=\"Library\")\n", " time = gr.Dropdown([\"3 months\", \"6 months\", \"9 months\", \"12 months\"],\n", " value=\"3 months\", label=\"Downloads over the last...\")\n", "\n", " plt = gr.LinePlot()\n", " # You can add multiple event triggers in 2 lines like this\n", " for event in [lib.change, time.change, demo.load]:\n", " event(get_plot, [lib, time], [plt])\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
@@ -4,16 +4,18 @@ from datetime import date
|
|
4 |
from dateutil.relativedelta import relativedelta
|
5 |
import pandas as pd
|
6 |
|
7 |
-
pd.options.plotting.backend = "plotly"
|
8 |
-
|
9 |
-
|
10 |
def get_plot(lib, time):
|
11 |
data = pypistats.overall(lib, total=True, format="pandas")
|
12 |
data = data.groupby("category").get_group("with_mirrors").sort_values("date")
|
13 |
start_date = date.today() - relativedelta(months=int(time.split(" ")[0]))
|
14 |
data = data[(data['date'] > str(start_date))]
|
15 |
-
|
16 |
-
return
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
with gr.Blocks() as demo:
|
@@ -23,12 +25,14 @@ with gr.Blocks() as demo:
|
|
23 |
See live download stats for all of Hugging Face's open-source libraries 🤗
|
24 |
""")
|
25 |
with gr.Row():
|
26 |
-
lib = gr.Dropdown(["transformers", "datasets", "huggingface-hub", "gradio", "accelerate"],
|
27 |
-
|
|
|
|
|
28 |
|
29 |
-
plt = gr.
|
30 |
# You can add multiple event triggers in 2 lines like this
|
31 |
-
for event in [lib.change, time.change]:
|
32 |
event(get_plot, [lib, time], [plt])
|
33 |
|
34 |
if __name__ == "__main__":
|
|
|
4 |
from dateutil.relativedelta import relativedelta
|
5 |
import pandas as pd
|
6 |
|
|
|
|
|
|
|
7 |
def get_plot(lib, time):
|
8 |
data = pypistats.overall(lib, total=True, format="pandas")
|
9 |
data = data.groupby("category").get_group("with_mirrors").sort_values("date")
|
10 |
start_date = date.today() - relativedelta(months=int(time.split(" ")[0]))
|
11 |
data = data[(data['date'] > str(start_date))]
|
12 |
+
data.date = pd.to_datetime(pd.to_datetime(data.date))
|
13 |
+
return gr.LinePlot.update(value=data, x="date", y="downloads",
|
14 |
+
tooltip=['date', 'downloads'],
|
15 |
+
title=f"Pypi downloads of {lib} over last {time}",
|
16 |
+
overlay_point=True,
|
17 |
+
height=400,
|
18 |
+
width=900)
|
19 |
|
20 |
|
21 |
with gr.Blocks() as demo:
|
|
|
25 |
See live download stats for all of Hugging Face's open-source libraries 🤗
|
26 |
""")
|
27 |
with gr.Row():
|
28 |
+
lib = gr.Dropdown(["transformers", "datasets", "huggingface-hub", "gradio", "accelerate"],
|
29 |
+
value="gradio", label="Library")
|
30 |
+
time = gr.Dropdown(["3 months", "6 months", "9 months", "12 months"],
|
31 |
+
value="3 months", label="Downloads over the last...")
|
32 |
|
33 |
+
plt = gr.LinePlot()
|
34 |
# You can add multiple event triggers in 2 lines like this
|
35 |
+
for event in [lib.change, time.change, demo.load]:
|
36 |
event(get_plot, [lib, time], [plt])
|
37 |
|
38 |
if __name__ == "__main__":
|