Spaces:
Runtime error
Runtime error
import gradio as gr | |
from fastai.learner import load_learner | |
from fastai.vision.core import PILImage | |
# Cargar el modelo entrenado desde Hugging Face | |
model_path = "model.pkl" | |
learn = Learner.load(model_path) | |
def predict(img): | |
pred_class, pred_idx, probs = learn.predict(PILImage.create(img)) | |
return f"Clase Predicha: {pred_class}, Probabilidad: {probs[pred_idx]:.4f}" | |
# Crear la interfaz con Gradio | |
demo = gr.Interface(fn=predict, | |
inputs=gr.Image(type="pil"), | |
outputs="text") | |
# Ejecutar la aplicación | |
demo.launch() | |