File size: 1,573 Bytes
acf354e
394a74f
3dfd005
e8b4e81
3dfd005
394a74f
acf354e
e8b4e81
acf354e
e8b4e81
3dfd005
e8b4e81
 
394a74f
e8b4e81
 
 
 
3dfd005
 
 
 
e8b4e81
3dfd005
 
 
 
 
 
 
 
 
 
 
e8b4e81
 
3dfd005
e8b4e81
 
394a74f
e8b4e81
3dfd005
e8b4e81
3dfd005
 
e8b4e81
3dfd005
e8b4e81
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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()