reddotapp25's picture
Create app.py
8399b2b verified
Raw
History Blame Contribute Delete
709 Bytes
import gradio as gr
from transformers import pipeline
# Load model - HF Spaces handles the caching automatically
print("Loading MobileNet...")
classifier = pipeline(
"image-classification",
model="google/mobilenet_v2_1.0_224"
)
def classify_image(img):
try:
results = classifier(img)
return {result['label']: float(result['score']) for result in results}
except Exception as e:
return {"Error": str(e)}
demo = gr.Interface(
fn=classify_image,
inputs=gr.Image(type="pil"),
outputs=gr.Label(num_top_classes=5),
title="📱 MobileNet Classifier",
description="Fast, lightweight image classification running on Hugging Face Spaces."
)
demo.launch()