Practica3 / app.py
JeanCGuerrero's picture
Update app.py
91554b5 verified
raw
history blame contribute delete
534 Bytes
import gradio as gr
from fastai.vision.core import PILImage
from huggingface_hub import from_pretrained_fastai
# Cargar directamente desde el repositorio en Hugging Face
learn = from_pretrained_fastai("jeancguerrero/fastai-simple-climate") # o el nombre que corresponda
def predict(img):
pred_class, pred_idx, probs = learn.predict(PILImage.create(img))
return f"Clase Predicha: {pred_class}, Probabilidad: {probs[pred_idx]:.4f}"
demo = gr.Interface(fn=predict, inputs=gr.Image(type="pil"), outputs="text")
demo.launch()