Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,45 +1,49 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
from huggingface_hub import HfApi
|
| 4 |
|
| 5 |
-
# Load HF token from environment variable
|
| 6 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 7 |
|
| 8 |
# Initialize HF API
|
| 9 |
api = HfApi(token=HF_TOKEN)
|
| 10 |
|
| 11 |
-
def
|
| 12 |
output = ""
|
| 13 |
try:
|
| 14 |
-
# Get all models (repositories) for the user
|
| 15 |
repos = api.list_models(author=username, token=HF_TOKEN)
|
| 16 |
if not repos:
|
| 17 |
return f"No repositories found for user '{username}'"
|
| 18 |
|
| 19 |
for repo in repos:
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
try:
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
except Exception as e:
|
| 32 |
return f"Error: {e}"
|
| 33 |
-
|
| 34 |
return output
|
| 35 |
|
| 36 |
# Gradio UI
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
-
gr.Markdown("## Hugging Face
|
| 39 |
username_input = gr.Textbox(label="Hugging Face Username", value="rahul7star")
|
| 40 |
-
scan_button = gr.Button("
|
| 41 |
-
output_box = gr.Textbox(label="
|
| 42 |
|
| 43 |
-
scan_button.click(
|
| 44 |
|
| 45 |
demo.launch()
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from huggingface_hub import HfApi
|
| 4 |
|
| 5 |
+
# Load HF token from environment variable if needed
|
| 6 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 7 |
|
| 8 |
# Initialize HF API
|
| 9 |
api = HfApi(token=HF_TOKEN)
|
| 10 |
|
| 11 |
+
def check_zero_gpu(username: str):
|
| 12 |
output = ""
|
| 13 |
try:
|
|
|
|
| 14 |
repos = api.list_models(author=username, token=HF_TOKEN)
|
| 15 |
if not repos:
|
| 16 |
return f"No repositories found for user '{username}'"
|
| 17 |
|
| 18 |
for repo in repos:
|
| 19 |
+
# Default: assume ZeroGPU
|
| 20 |
+
zero_gpu = "Yes"
|
| 21 |
+
|
| 22 |
+
# Check model card for hardware requirements
|
| 23 |
try:
|
| 24 |
+
card = api.model_info(repo_id=repo.modelId, token=HF_TOKEN)
|
| 25 |
+
# If model has 'hardware' in card, and it mentions GPU, mark as No
|
| 26 |
+
if hasattr(card, "hardware") and card.hardware:
|
| 27 |
+
if any("gpu" in h.lower() for h in card.hardware):
|
| 28 |
+
zero_gpu = "No"
|
| 29 |
+
except Exception:
|
| 30 |
+
# If info not available, keep as Yes
|
| 31 |
+
pass
|
| 32 |
+
|
| 33 |
+
output += f"{repo.modelId} | ZeroGPU: {zero_gpu}\n"
|
| 34 |
+
|
| 35 |
except Exception as e:
|
| 36 |
return f"Error: {e}"
|
| 37 |
+
|
| 38 |
return output
|
| 39 |
|
| 40 |
# Gradio UI
|
| 41 |
with gr.Blocks() as demo:
|
| 42 |
+
gr.Markdown("## Hugging Face Repo ZeroGPU Checker")
|
| 43 |
username_input = gr.Textbox(label="Hugging Face Username", value="rahul7star")
|
| 44 |
+
scan_button = gr.Button("Check Repositories")
|
| 45 |
+
output_box = gr.Textbox(label="ZeroGPU Status", lines=25)
|
| 46 |
|
| 47 |
+
scan_button.click(check_zero_gpu, inputs=username_input, outputs=output_box)
|
| 48 |
|
| 49 |
demo.launch()
|