davanstrien HF staff commited on
Commit
538d051
1 Parent(s): 3533641

close by default

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -39,12 +39,14 @@ df = pd.DataFrame(
39
  ).reset_index()
40
  df_with_org = df.copy(deep=True)
41
 
 
42
  def parse_org(hub_id):
43
- parts = hub_id.split('/')
44
  return parts[0] if len(parts) == 2 else None
45
 
 
46
  df_with_org["org"] = df_with_org["base_model"].apply(parse_org)
47
- df_with_org = df_with_org.dropna(subset=['org'])
48
 
49
  grouped_by_base_model = groupby(
50
  lambda x: x.cardData.get("base_model"), models_with_base_model_info
@@ -79,16 +81,17 @@ with gr.Blocks() as demo:
79
  base_model = gr.Dropdown(all_base_models, label="Base Model")
80
  results = gr.Markdown()
81
  base_model.change(return_models_for_base_model, base_model, results)
82
- with gr.Accordion("Base model popularity ranking"):
83
  gr.DataFrame(df.head(50))
84
- with gr.Accordion("Base model popularity ranking by organisation"):
85
  gr.DataFrame(
86
  pd.DataFrame(
87
- df_with_org.groupby("org")["count"]
88
- .sum()
89
- .sort_values(ascending=False)
90
- .head(50)
91
- ).reset_index()).sort_values("count", ascending=False)
 
92
 
93
 
94
  demo.launch()
 
39
  ).reset_index()
40
  df_with_org = df.copy(deep=True)
41
 
42
+
43
  def parse_org(hub_id):
44
+ parts = hub_id.split("/")
45
  return parts[0] if len(parts) == 2 else None
46
 
47
+
48
  df_with_org["org"] = df_with_org["base_model"].apply(parse_org)
49
+ df_with_org = df_with_org.dropna(subset=["org"])
50
 
51
  grouped_by_base_model = groupby(
52
  lambda x: x.cardData.get("base_model"), models_with_base_model_info
 
81
  base_model = gr.Dropdown(all_base_models, label="Base Model")
82
  results = gr.Markdown()
83
  base_model.change(return_models_for_base_model, base_model, results)
84
+ with gr.Accordion("Base model popularity ranking", open=False):
85
  gr.DataFrame(df.head(50))
86
+ with gr.Accordion("Base model popularity ranking by organisation", open=False):
87
  gr.DataFrame(
88
  pd.DataFrame(
89
+ df_with_org.groupby("org")["count"]
90
+ .sum()
91
+ .sort_values(ascending=False)
92
+ .head(50)
93
+ ).reset_index()
94
+ ).sort_values("count", ascending=False)
95
 
96
 
97
  demo.launch()