Entregable3 / app.py
pabpelle's picture
Update app.py
136a590 verified
raw
history blame contribute delete
464 Bytes
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from fastai.vision.all import *
repo_id = "pabpelle/entregable3"
learner = from_pretrained_fastai(repo_id)
labels = ["No toxic", "Toxic"]
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.Text(), outputs=gr.Label(num_top_classes=2), examples=[]).launch(share=False)