Spaces:
Runtime error
Runtime error
File size: 1,168 Bytes
450ba14 c296338 450ba14 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import gradio as gr
import pypistats
from datetime import date
from dateutil.relativedelta import relativedelta
import pandas as pd
pd.options.plotting.backend = "plotly"
def get_plot(lib, time):
data = pypistats.overall(lib, total=True, format="pandas")
data = data.groupby("category").get_group("with_mirrors").sort_values("date")
start_date = date.today() - relativedelta(months=int(time.split(" ")[0]))
data = data[(data['date'] > str(start_date))]
chart = data.plot(x="date", y="downloads")
return chart
with gr.Blocks() as demo:
gr.Markdown(
"""
## Pypi Download Stats π
See live download stats for all of Hugging Face's open-source libraries π€
""")
with gr.Row():
lib = gr.Dropdown(["transformers", "datasets", "huggingface-hub", "gradio", "accelerate", "optimum", "evaluate", "diffusers"], label="Library")
time = gr.Dropdown(["3 months", "6 months", "9 months", "12 months"], label="Downloads over the last...")
plt = gr.Plot()
lib.change(get_plot, [lib, time], plt)
time.change(get_plot, [lib, time], plt)
demo.load(get_plot, [lib, time], plt)
demo.launch() |