Spaces:
Sleeping
Sleeping
| import os | |
| import gradio as gr | |
| from huggingface_hub import HfApi | |
| # Load HF token from environment variable if needed | |
| HF_TOKEN = os.getenv("HF_TOKEN") | |
| # Initialize HF API | |
| api = HfApi(token=HF_TOKEN) | |
| def check_zero_gpu(username: str): | |
| output = "" | |
| try: | |
| repos = api.list_models(author=username, token=HF_TOKEN) | |
| if not repos: | |
| return f"No repositories found for user '{username}'" | |
| for repo in repos: | |
| # Default: assume ZeroGPU | |
| zero_gpu = "Yes" | |
| # Check model card for hardware requirements | |
| try: | |
| card = api.model_info(repo_id=repo.modelId, token=HF_TOKEN) | |
| # If model has 'hardware' in card, and it mentions GPU, mark as No | |
| if hasattr(card, "hardware") and card.hardware: | |
| if any("gpu" in h.lower() for h in card.hardware): | |
| zero_gpu = "No" | |
| except Exception: | |
| # If info not available, keep as Yes | |
| pass | |
| output += f"{repo.modelId} | ZeroGPU: {zero_gpu}\n" | |
| except Exception as e: | |
| return f"Error: {e}" | |
| return output | |
| # Gradio UI | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## Hugging Face Repo ZeroGPU Checker") | |
| username_input = gr.Textbox(label="Hugging Face Username", value="rahul7star") | |
| scan_button = gr.Button("Check Repositories") | |
| output_box = gr.Textbox(label="ZeroGPU Status", lines=25) | |
| scan_button.click(check_zero_gpu, inputs=username_input, outputs=output_box) | |
| demo.launch() | |