Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,89 +1,38 @@
|
|
| 1 |
-
from datasets import load_dataset
|
| 2 |
-
from huggingface_hub import ModelCard
|
| 3 |
-
from huggingface_hub import HfApi
|
| 4 |
-
|
| 5 |
import gradio as gr
|
|
|
|
|
|
|
| 6 |
import pandas as pd
|
| 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 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
data = pd.DataFrame(
|
| 44 |
-
{
|
| 45 |
-
"name": ["Total Number of transformers Model", "Total number of models with missing 'library_name: transformers' in model card."],
|
| 46 |
-
"count": [len(ds), sum(ds["missing_library_name"])],
|
| 47 |
-
}
|
| 48 |
-
)
|
| 49 |
-
return data
|
| 50 |
-
|
| 51 |
-
def fetch_fn(commit_date="latest"):
|
| 52 |
-
data = get_data(commit_date=commit_date)
|
| 53 |
-
return gr.BarPlot(
|
| 54 |
-
data,
|
| 55 |
-
x="name",
|
| 56 |
-
y="count",
|
| 57 |
-
title="Count of Model cards with the correct library_name tag",
|
| 58 |
-
height=256,
|
| 59 |
-
width=1024,
|
| 60 |
-
tooltip=["name", "count"],
|
| 61 |
-
vertical=False
|
| 62 |
-
)
|
| 63 |
-
|
| 64 |
-
data = get_data()
|
| 65 |
-
|
| 66 |
-
with gr.Blocks() as bar_plot:
|
| 67 |
-
with gr.Column():
|
| 68 |
-
with gr.Row():
|
| 69 |
-
plot = gr.BarPlot(
|
| 70 |
-
data,
|
| 71 |
-
x="name",
|
| 72 |
-
y="count",
|
| 73 |
-
title=f"Count of Model cards with the correct library_name tag at the date {current_date}",
|
| 74 |
-
height=256,
|
| 75 |
-
width=1024,
|
| 76 |
-
tooltip=["name", "count"],
|
| 77 |
-
vertical=False
|
| 78 |
-
)
|
| 79 |
-
with gr.Column():
|
| 80 |
-
display = gr.Dropdown(
|
| 81 |
-
choices=list(commits_date_dict.keys()),
|
| 82 |
-
value="latest",
|
| 83 |
-
label="Type of Bar Plot",
|
| 84 |
-
|
| 85 |
-
)
|
| 86 |
-
|
| 87 |
-
display.change(fetch_fn, inputs=display, outputs=plot)
|
| 88 |
-
|
| 89 |
-
bar_plot.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import altair as alt
|
| 3 |
+
from datasets import load_dataset
|
| 4 |
import pandas as pd
|
| 5 |
|
| 6 |
+
model_id = "ybelkada/model_cards_correct_tag"
|
| 7 |
+
dataset = load_dataset(model_id, split="train").to_pandas()
|
| 8 |
+
|
| 9 |
+
# Convert dataset to a pandas DataFrame and sort by commit_dates
|
| 10 |
+
df = pd.DataFrame(dataset)
|
| 11 |
+
df["commit_dates"] = pd.to_datetime(df["commit_dates"]) # Convert commit_dates to datetime format
|
| 12 |
+
df = df.sort_values(by="commit_dates")
|
| 13 |
+
|
| 14 |
+
def plot_fn():
|
| 15 |
+
line_chart = alt.Chart(df).mark_line().encode(
|
| 16 |
+
x=alt.X('commit_dates:T', axis=alt.Axis(title='Date')),
|
| 17 |
+
y=alt.Y('total_transformers_model:Q', axis=alt.Axis(title='Count'), scale=alt.Scale(zero=False)),
|
| 18 |
+
color=alt.value('blue'),
|
| 19 |
+
tooltip=['commit_dates:T', 'total_transformers_model:Q'],
|
| 20 |
+
).properties(width=600, height=400)
|
| 21 |
+
|
| 22 |
+
line_chart_missing_library = alt.Chart(df).mark_line().encode(
|
| 23 |
+
x=alt.X('commit_dates:T', axis=alt.Axis(title='Date')),
|
| 24 |
+
y=alt.Y('missing_library_name:Q', axis=alt.Axis(title='Count'), scale=alt.Scale(zero=False)),
|
| 25 |
+
color=alt.value('orange'),
|
| 26 |
+
tooltip=['commit_dates:T', 'missing_library_name:Q'],
|
| 27 |
+
).properties(width=600, height=400)
|
| 28 |
+
|
| 29 |
+
chart = (line_chart + line_chart_missing_library).properties(width=600, height=400)
|
| 30 |
+
|
| 31 |
+
return chart
|
| 32 |
+
|
| 33 |
+
with gr.Blocks() as demo:
|
| 34 |
+
plot = gr.Plot(label="Plot")
|
| 35 |
+
demo.load(plot_fn, inputs=[], outputs=[plot])
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|