Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from fastai.vision.all import * | |
| from huggingface_hub import hf_hub_download | |
| # Descargar el modelo desde Hugging Face Hub | |
| model_path = hf_hub_download( | |
| repo_id="pagaliv/futurama-character-classifier", | |
| filename="model.pkl" | |
| ) | |
| import os | |
| os.system('pip install --force-reinstall numpy==1.24.4') | |
| from fastai.learner import load_learner | |
| modelo = load_learner(model_path) | |
| # Cargar el modelo descargado | |
| modelo = load_learner(model_path) | |
| # Funci贸n de clasificaci贸n | |
| def clasificar_imagen(img): | |
| pred, _, prob = modelo.predict(img) | |
| return {modelo.dls.vocab[i]: float(prob[i]) for i in range(len(prob))} | |
| # Interfaz Gradio | |
| titulo = "Clasificador de personajes de Futurama" | |
| ejemplos = ["B1.png", "F1.png", "L1.png"] # Nombres de tus im谩genes subidas | |
| iface = gr.Interface( | |
| fn=clasificar_imagen, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Label(num_top_classes=3), | |
| title=titulo, | |
| examples=ejemplos | |
| ) | |
| iface.launch() | |