Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -42,7 +42,6 @@ def fetch_stats():
|
|
42 |
except Exception as e:
|
43 |
print(f"Error fetching {model_id}: {str(e)}")
|
44 |
|
45 |
-
# Fetch derivative models - using the tag format that works
|
46 |
model_types = ["adapter", "finetune", "merge", "quantized"]
|
47 |
base_models = [
|
48 |
"DeepSeek-R1",
|
@@ -60,7 +59,6 @@ def fetch_stats():
|
|
60 |
for base_model in base_models:
|
61 |
for model_type in model_types:
|
62 |
try:
|
63 |
-
# Get models for this type
|
64 |
models = list(api.list_models(
|
65 |
filter=f"base_model:{model_type}:deepseek-ai/{base_model}",
|
66 |
full=True
|
@@ -88,31 +86,27 @@ def create_stats_html():
|
|
88 |
"""Create HTML for displaying statistics"""
|
89 |
original_df, derivative_df = fetch_stats()
|
90 |
|
91 |
-
# Create summary statistics
|
92 |
total_originals = len(original_df)
|
93 |
total_derivatives = len(derivative_df)
|
94 |
total_downloads_orig = original_df['downloads_30d'].sum()
|
95 |
total_downloads_deriv = derivative_df['downloads_30d'].sum()
|
96 |
|
97 |
-
# Create derivative type distribution chart
|
98 |
if len(derivative_df) > 0:
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
y='downloads_30d',
|
110 |
-
title='Total Downloads by Model Type',
|
111 |
-
labels={'downloads_30d': 'Downloads', 'model_type': 'Model Type'},
|
112 |
-
text=type_dist['downloads_30d'].apply(format_number)
|
113 |
-
)
|
114 |
|
115 |
-
# Update layout for log scale and better appearance
|
116 |
fig_types.update_layout(
|
117 |
yaxis=dict(
|
118 |
type='log',
|
@@ -120,8 +114,8 @@ def create_stats_html():
|
|
120 |
),
|
121 |
showlegend=False,
|
122 |
plot_bgcolor='white',
|
123 |
-
autosize=True,
|
124 |
-
margin=dict(
|
125 |
l=50,
|
126 |
r=50,
|
127 |
t=100,
|
@@ -130,13 +124,11 @@ def create_stats_html():
|
|
130 |
)
|
131 |
)
|
132 |
|
133 |
-
# Update bars and text
|
134 |
fig_types.update_traces(
|
135 |
textposition='outside',
|
136 |
cliponaxis=False
|
137 |
)
|
138 |
|
139 |
-
# Configure for responsive behavior
|
140 |
fig_types.update_layout(
|
141 |
{
|
142 |
'xaxis': {'automargin': True},
|
@@ -152,7 +144,7 @@ def create_stats_html():
|
|
152 |
if len(derivative_df) > 0:
|
153 |
top_models = derivative_df.nlargest(10, 'downloads_30d')[
|
154 |
['model_id', 'model_type', 'downloads_30d', 'likes']
|
155 |
-
].copy()
|
156 |
|
157 |
# Capitalize model types in the table
|
158 |
top_models['model_type'] = top_models['model_type'].str.capitalize()
|
|
|
42 |
except Exception as e:
|
43 |
print(f"Error fetching {model_id}: {str(e)}")
|
44 |
|
|
|
45 |
model_types = ["adapter", "finetune", "merge", "quantized"]
|
46 |
base_models = [
|
47 |
"DeepSeek-R1",
|
|
|
59 |
for base_model in base_models:
|
60 |
for model_type in model_types:
|
61 |
try:
|
|
|
62 |
models = list(api.list_models(
|
63 |
filter=f"base_model:{model_type}:deepseek-ai/{base_model}",
|
64 |
full=True
|
|
|
86 |
"""Create HTML for displaying statistics"""
|
87 |
original_df, derivative_df = fetch_stats()
|
88 |
|
|
|
89 |
total_originals = len(original_df)
|
90 |
total_derivatives = len(derivative_df)
|
91 |
total_downloads_orig = original_df['downloads_30d'].sum()
|
92 |
total_downloads_deriv = derivative_df['downloads_30d'].sum()
|
93 |
|
|
|
94 |
if len(derivative_df) > 0:
|
95 |
+
type_dist = derivative_df.groupby('model_type').agg({
|
96 |
+
'model_id': 'count',
|
97 |
+
'downloads_30d': 'sum'
|
98 |
+
}).reset_index()
|
99 |
+
type_dist['model_type'] = type_dist['model_type'].str.capitalize()
|
100 |
+
type_dist = type_dist.sort_values('downloads_30d', ascending=True)
|
101 |
|
102 |
+
fig_types = go.Figure(data=[
|
103 |
+
go.Bar(
|
104 |
+
x=list(type_dist['model_type']),
|
105 |
+
y=list(type_dist['downloads_30d'].values),
|
106 |
+
marker_color='rgb(55, 83, 109)'
|
107 |
+
)
|
108 |
+
])
|
|
|
|
|
|
|
|
|
|
|
109 |
|
|
|
110 |
fig_types.update_layout(
|
111 |
yaxis=dict(
|
112 |
type='log',
|
|
|
114 |
),
|
115 |
showlegend=False,
|
116 |
plot_bgcolor='white',
|
117 |
+
autosize=True,
|
118 |
+
margin=dict(
|
119 |
l=50,
|
120 |
r=50,
|
121 |
t=100,
|
|
|
124 |
)
|
125 |
)
|
126 |
|
|
|
127 |
fig_types.update_traces(
|
128 |
textposition='outside',
|
129 |
cliponaxis=False
|
130 |
)
|
131 |
|
|
|
132 |
fig_types.update_layout(
|
133 |
{
|
134 |
'xaxis': {'automargin': True},
|
|
|
144 |
if len(derivative_df) > 0:
|
145 |
top_models = derivative_df.nlargest(10, 'downloads_30d')[
|
146 |
['model_id', 'model_type', 'downloads_30d', 'likes']
|
147 |
+
].copy()
|
148 |
|
149 |
# Capitalize model types in the table
|
150 |
top_models['model_type'] = top_models['model_type'].str.capitalize()
|