Practica9 / app.py
alramil's picture
Update app.py
8f20b61 verified
raw
history blame contribute delete
835 Bytes
import gradio as gr
from transformers import pipeline
import torch
# Reemplaza por tu identificador de modelo:
REPO_ID = "alramil/Practica9"
# Creamos pipeline cargando directamente del Hub
classifier = pipeline(
"text-classification",
model=REPO_ID,
tokenizer=REPO_ID,
return_all_scores=True,
device=0 if torch.cuda.is_available() else -1
)
def classify(text: str):
outputs = classifier(text)
return { d["label"]: float(d["score"]) for d in outputs }
iface = gr.Interface(
fn=classify,
inputs=gr.Textbox(lines=5, placeholder="Escribe tu texto aquí…"),
outputs=gr.Label(num_top_classes=3),
title="🧠 Clasificador Practica9",
description=f"Modelo cargado desde Hugging Face Hub: `{REPO_ID}`"
)
if __name__ == "__main__":
iface.launch(server_name="0.0.0.0", server_port=7860)