Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
-
import os
|
2 |
import gradio as gr
|
|
|
3 |
from repo_utils import extract_repo_content
|
|
|
4 |
|
5 |
def format_output(extracted_content, repo_url):
|
6 |
formatted_output = f"# Repository URL: {repo_url}\n\n"
|
@@ -26,24 +27,37 @@ def extract_and_display(url):
|
|
26 |
formatted_output = format_output(extracted_content, url)
|
27 |
return formatted_output
|
28 |
|
|
|
|
|
|
|
|
|
|
|
29 |
app = gr.Blocks(theme="sudeepshouche/minimalist")
|
30 |
|
31 |
with app:
|
32 |
-
gr.
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
[
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
if __name__ == "__main__":
|
49 |
app.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
from repo_utils import extract_repo_content
|
4 |
+
from utils import get_model_summary
|
5 |
|
6 |
def format_output(extracted_content, repo_url):
|
7 |
formatted_output = f"# Repository URL: {repo_url}\n\n"
|
|
|
27 |
formatted_output = format_output(extracted_content, url)
|
28 |
return formatted_output
|
29 |
|
30 |
+
def handle_model_summary(model_name):
|
31 |
+
model_summary, error_message = get_model_summary(model_name)
|
32 |
+
return model_summary, error_message
|
33 |
+
|
34 |
+
# Create Gradio App
|
35 |
app = gr.Blocks(theme="sudeepshouche/minimalist")
|
36 |
|
37 |
with app:
|
38 |
+
with gr.Tab("Repository Extraction"):
|
39 |
+
gr.Markdown("# Hugging Face Space / Model Repository Content Extractor")
|
40 |
+
url_input = gr.Textbox(label="https:// URL of Repository", placeholder="Enter the repository URL here OR select an example below...")
|
41 |
+
url_examples = gr.Examples(
|
42 |
+
examples=[
|
43 |
+
["https://huggingface.co/spaces/big-vision/paligemma-hf"],
|
44 |
+
["https://huggingface.co/google/paligemma-3b-mix-224"],
|
45 |
+
["https://huggingface.co/microsoft/Phi-3-vision-128k-instruct"],
|
46 |
+
["https://huggingface.co/llava-hf/llava-v1.6-mistral-7b-hf"]
|
47 |
+
],
|
48 |
+
inputs=url_input
|
49 |
+
)
|
50 |
+
output_display = gr.Textbox(label="Extracted Repository Content", show_copy_button=True, lines=20, placeholder="Repository content will be extracted here...\n\nMetadata is captured for all files, but text content provided only for files less than 32 kb\n\n\n\nReview and search through the content here OR simply copy it for offline analysis!!. π€")
|
51 |
+
extract_button = gr.Button("Extract Content")
|
52 |
+
extract_button.click(fn=extract_and_display, inputs=url_input, outputs=output_display)
|
53 |
|
54 |
+
with gr.Tab("Model Explorer"):
|
55 |
+
gr.Markdown("## Retrieve and Display Model Architecture")
|
56 |
+
model_name_input = gr.Textbox(label="Model Name", placeholder="Enter the model name to retrieve its architecture...")
|
57 |
+
model_output = gr.Textbox(label="Model Architecture", lines=20, placeholder="Model architecture will appear here...", show_copy_button=True)
|
58 |
+
error_output = gr.Textbox(label="Error", lines=10, placeholder="Exceptions will appear here...", show_copy_button=True)
|
59 |
+
model_submit_button = gr.Button("Submit")
|
60 |
+
model_submit_button.click(fn=handle_model_summary, inputs=model_name_input, outputs=[model_output, error_output])
|
61 |
|
62 |
if __name__ == "__main__":
|
63 |
app.launch()
|