entregable3 / app.py
ivferns's picture
Update app.py
54a5a80 verified
raw
history blame contribute delete
704 Bytes
from fastai.learner import load_learner
import gradio as gr
from huggingface_hub import from_pretrained_fastai
# Carga del modelo desde HuggingFace Hub
learn = from_pretrained_fastai("ivferns/clasificador_textos")
# Función de predicción
def clasificar_texto(texto):
pred, idx, probs = learn.predict(texto)
return str(pred)
# Interfaz Gradio
iface = gr.Interface(
fn=clasificar_texto,
inputs=gr.Textbox(lines=5, label="Introduce el texto"),
outputs=gr.Label(label="Prediccion"),
title="Clasificador de textos",
description="Modelo de clasificación de textos fine-tuned con FastAI y desplegado en Hugging Face Spaces."
)
if __name__ == "__main__":
iface.launch()