aliabd commited on
Commit
cc7ce03
·
1 Parent(s): de2577c

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +8 -8
  2. requirements.txt +2 -0
  3. run.ipynb +1 -0
  4. run.py +39 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Blocks Multiple Event Triggers 3-x
3
- emoji: 📚
4
- colorFrom: purple
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 4.3.0
8
- app_file: app.py
9
  pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: blocks_multiple_event_triggers_3-x
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 3.50.1
9
+ app_file: run.py
10
  pinned: false
11
+ hf_oauth: true
12
  ---
 
 
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ plotly
2
+ pypistats
run.ipynb ADDED
@@ -0,0 +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", "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(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 ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pypistats
3
+ from datetime import date
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(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:
22
+ gr.Markdown(
23
+ """
24
+ ## Pypi Download Stats 📈
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__":
39
+ demo.launch()