fdaudens HF Staff commited on
Commit
5b391e3
·
1 Parent(s): 8c6fcfb
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -63,9 +63,6 @@ def get_model_stats(search_term):
63
  # Return both the DataFrame, status message, and the CSV file path
64
  return df, status_message, str(output_file)
65
 
66
- def format_model_link(model_id):
67
- return f'<a href="https://huggingface.co/{model_id}" target="_blank">{model_id}</a>'
68
-
69
  # Create the Gradio interface
70
  with gr.Blocks(title="Hugging Face Model Statistics") as demo:
71
  gr.Markdown("# Hugging Face Model Statistics")
@@ -80,13 +77,14 @@ with gr.Blocks(title="Hugging Face Model Statistics") as demo:
80
  search_button = gr.Button("Search")
81
 
82
  with gr.Row():
83
- output_table = gr.Dataframe(
84
- headers=["Model ID", "Downloads (30 days)", "Downloads (All Time)"],
85
- datatype=["str", "number", "number"],
86
- label="Model Statistics",
87
- wrap=True
88
- )
89
- status_message = gr.Textbox(label="Status", lines=3) # Increased lines to show all stats
 
90
 
91
  with gr.Row():
92
  download_button = gr.Button("Download CSV")
@@ -96,8 +94,14 @@ with gr.Blocks(title="Hugging Face Model Statistics") as demo:
96
  csv_path = gr.State()
97
 
98
  def process_results(df, status, csv_path):
99
- # Format the model IDs as clickable links
100
- df['Model ID'] = df['Model ID'].apply(format_model_link)
 
 
 
 
 
 
101
  return df, status, csv_path
102
 
103
  search_button.click(
 
63
  # Return both the DataFrame, status message, and the CSV file path
64
  return df, status_message, str(output_file)
65
 
 
 
 
66
  # Create the Gradio interface
67
  with gr.Blocks(title="Hugging Face Model Statistics") as demo:
68
  gr.Markdown("# Hugging Face Model Statistics")
 
77
  search_button = gr.Button("Search")
78
 
79
  with gr.Row():
80
+ with gr.Column():
81
+ output_table = gr.Dataframe(
82
+ headers=["Model ID", "Downloads (30 days)", "Downloads (All Time)"],
83
+ datatype=["str", "number", "number"],
84
+ label="Model Statistics",
85
+ wrap=True
86
+ )
87
+ status_message = gr.Textbox(label="Status", lines=3)
88
 
89
  with gr.Row():
90
  download_button = gr.Button("Download CSV")
 
94
  csv_path = gr.State()
95
 
96
  def process_results(df, status, csv_path):
97
+ # Create HTML links for each model
98
+ html_links = []
99
+ for model_id in df['Model ID']:
100
+ html_links.append(f'<a href="https://huggingface.co/{model_id}" target="_blank">{model_id}</a>')
101
+
102
+ # Update the DataFrame with HTML links
103
+ df['Model ID'] = html_links
104
+
105
  return df, status, csv_path
106
 
107
  search_button.click(