clickable links
Browse files
app.py
CHANGED
@@ -53,9 +53,6 @@ def get_model_stats(search_term):
|
|
53 |
# Read the CSV file into a pandas DataFrame
|
54 |
df = pd.read_csv(output_file)
|
55 |
|
56 |
-
# Create clickable links for model IDs
|
57 |
-
df['Model ID'] = df['Model ID'].apply(lambda x: f'<a href="https://huggingface.co/{x}" target="_blank">{x}</a>')
|
58 |
-
|
59 |
# Create status message with total downloads
|
60 |
status_message = (
|
61 |
f"Found {model_count} models for search term '{search_term}'\n"
|
@@ -66,6 +63,9 @@ def get_model_stats(search_term):
|
|
66 |
# Return both the DataFrame, status message, and the CSV file path
|
67 |
return df, status_message, str(output_file)
|
68 |
|
|
|
|
|
|
|
69 |
# Create the Gradio interface
|
70 |
with gr.Blocks(title="Hugging Face Model Statistics") as demo:
|
71 |
gr.Markdown("# Hugging Face Model Statistics")
|
@@ -95,10 +95,19 @@ with gr.Blocks(title="Hugging Face Model Statistics") as demo:
|
|
95 |
# Store the CSV file path in a state
|
96 |
csv_path = gr.State()
|
97 |
|
|
|
|
|
|
|
|
|
|
|
98 |
search_button.click(
|
99 |
fn=get_model_stats,
|
100 |
inputs=search_input,
|
101 |
outputs=[output_table, status_message, csv_path]
|
|
|
|
|
|
|
|
|
102 |
)
|
103 |
|
104 |
download_button.click(
|
|
|
53 |
# Read the CSV file into a pandas DataFrame
|
54 |
df = pd.read_csv(output_file)
|
55 |
|
|
|
|
|
|
|
56 |
# Create status message with total downloads
|
57 |
status_message = (
|
58 |
f"Found {model_count} models for search term '{search_term}'\n"
|
|
|
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")
|
|
|
95 |
# Store the CSV file path in a state
|
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(
|
104 |
fn=get_model_stats,
|
105 |
inputs=search_input,
|
106 |
outputs=[output_table, status_message, csv_path]
|
107 |
+
).then(
|
108 |
+
fn=process_results,
|
109 |
+
inputs=[output_table, status_message, csv_path],
|
110 |
+
outputs=[output_table, status_message, csv_path]
|
111 |
)
|
112 |
|
113 |
download_button.click(
|