Spaces:
Sleeping
Sleeping
| from transformers import pipeline | |
| import gradio as gr | |
| # Load model ONCE at startup | |
| pipe = pipeline("image-classification", model="skshmjn/Pokemon-classifier-gen9-1025") | |
| def classify_pokemon(img): | |
| predictions = pipe(img) | |
| # Return top 3 as list of (label, confidence) | |
| return {pred["label"]: pred["score"] for pred in predictions[:3]} | |
| # Gradio interface | |
| gr.Interface( | |
| fn=classify_pokemon, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Label(num_top_classes=3), | |
| title="Pokémon Classifier", | |
| description="Upload an image of a Pokémon to identify it!" | |
| ).launch() |