entregable3 / app.py
osrandez's picture
Create app.py
7bee398
raw
history blame
464 Bytes
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from fastai.vision.all import *
repo_id = "osrandez/sst2"
labels = ['mala','buena']
learner = from_pretrained_fastai(repo_id)
def predict(text):
pred,pred_idx,probs = learner.predict(text)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(), outputs=gr.outputs.Label(num_top_classes=2)).launch(share=False,debug=True)