Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,29 +8,28 @@ HF_TOKEN = os.getenv("HF_TOKEN")
|
|
| 8 |
# Initialize HF API
|
| 9 |
api = HfApi(token=HF_TOKEN)
|
| 10 |
|
| 11 |
-
def
|
| 12 |
output = ""
|
| 13 |
try:
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
for
|
| 19 |
# Default: assume ZeroGPU
|
| 20 |
zero_gpu = "Yes"
|
| 21 |
|
| 22 |
-
# Check
|
| 23 |
try:
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
if any("gpu" in h.lower() for h in card.hardware):
|
| 28 |
zero_gpu = "No"
|
| 29 |
except Exception:
|
| 30 |
-
#
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
output += f"{repo.modelId} | ZeroGPU: {zero_gpu}\n"
|
| 34 |
|
| 35 |
except Exception as e:
|
| 36 |
return f"Error: {e}"
|
|
@@ -39,11 +38,11 @@ def check_zero_gpu(username: str):
|
|
| 39 |
|
| 40 |
# Gradio UI
|
| 41 |
with gr.Blocks() as demo:
|
| 42 |
-
gr.Markdown("## Hugging Face
|
| 43 |
username_input = gr.Textbox(label="Hugging Face Username", value="rahul7star")
|
| 44 |
-
scan_button = gr.Button("Check
|
| 45 |
output_box = gr.Textbox(label="ZeroGPU Status", lines=25)
|
| 46 |
|
| 47 |
-
scan_button.click(
|
| 48 |
|
| 49 |
demo.launch()
|
|
|
|
| 8 |
# Initialize HF API
|
| 9 |
api = HfApi(token=HF_TOKEN)
|
| 10 |
|
| 11 |
+
def check_spaces_zero_gpu(username: str):
|
| 12 |
output = ""
|
| 13 |
try:
|
| 14 |
+
# List all spaces for the user
|
| 15 |
+
spaces = api.list_spaces(author=username, token=HF_TOKEN)
|
| 16 |
+
if not spaces:
|
| 17 |
+
return f"No Spaces found for user '{username}'"
|
| 18 |
|
| 19 |
+
for space in spaces:
|
| 20 |
# Default: assume ZeroGPU
|
| 21 |
zero_gpu = "Yes"
|
| 22 |
|
| 23 |
+
# Check if space requires GPU
|
| 24 |
try:
|
| 25 |
+
space_info = api.space_info(space_id=space.id, token=HF_TOKEN)
|
| 26 |
+
if getattr(space_info, "hardware", None):
|
| 27 |
+
if any("gpu" in h.lower() for h in space_info.hardware):
|
|
|
|
| 28 |
zero_gpu = "No"
|
| 29 |
except Exception:
|
| 30 |
+
pass # Keep as Yes if info unavailable
|
| 31 |
+
|
| 32 |
+
output += f"{space.id} | ZeroGPU: {zero_gpu}\n"
|
|
|
|
| 33 |
|
| 34 |
except Exception as e:
|
| 35 |
return f"Error: {e}"
|
|
|
|
| 38 |
|
| 39 |
# Gradio UI
|
| 40 |
with gr.Blocks() as demo:
|
| 41 |
+
gr.Markdown("## Hugging Face Spaces ZeroGPU Checker")
|
| 42 |
username_input = gr.Textbox(label="Hugging Face Username", value="rahul7star")
|
| 43 |
+
scan_button = gr.Button("Check Spaces")
|
| 44 |
output_box = gr.Textbox(label="ZeroGPU Status", lines=25)
|
| 45 |
|
| 46 |
+
scan_button.click(check_spaces_zero_gpu, inputs=username_input, outputs=output_box)
|
| 47 |
|
| 48 |
demo.launch()
|