Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from huggingface_hub import list_models, list_spaces
|
| 3 |
+
|
| 4 |
+
def browse_loras(limit=20):
|
| 5 |
+
models = list_models(
|
| 6 |
+
tags=["lora"],
|
| 7 |
+
sort="downloads",
|
| 8 |
+
direction=-1,
|
| 9 |
+
limit=limit,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
return "\n---\n".join(
|
| 13 |
+
f"### {m.modelId}\n"
|
| 14 |
+
f"⬇️ {m.downloads or 0} | ⭐ {m.likes or 0}\n"
|
| 15 |
+
f"https://huggingface.co/{m.modelId}"
|
| 16 |
+
for m in models
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
def browse_workflows(limit=20):
|
| 20 |
+
spaces = list_spaces(
|
| 21 |
+
sort="likes",
|
| 22 |
+
direction=-1,
|
| 23 |
+
limit=limit,
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# lightweight heuristic filter
|
| 27 |
+
workflows = [
|
| 28 |
+
s for s in spaces
|
| 29 |
+
if any(
|
| 30 |
+
tag in (s.tags or [])
|
| 31 |
+
for tag in ["comfyui", "workflow", "pipeline", "diffusers"]
|
| 32 |
+
)
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
return "\n---\n".join(
|
| 36 |
+
f"### {s.id}\n"
|
| 37 |
+
f"⭐ {s.likes or 0}\n"
|
| 38 |
+
f"https://huggingface.co/spaces/{s.id}"
|
| 39 |
+
for s in workflows[:limit]
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
with gr.Blocks() as demo:
|
| 43 |
+
gr.Markdown("# 🤗 Workflow & LoRA Browser")
|
| 44 |
+
|
| 45 |
+
with gr.Tabs():
|
| 46 |
+
with gr.Tab("⚙️ Workflows"):
|
| 47 |
+
wf_out = gr.Markdown()
|
| 48 |
+
gr.Button
|