nlmaldonadog's picture
Update app.py
8aa3570 verified
raw
history blame
948 Bytes
# import gradio as gr
# from transformers import pipeline
# classifier = pipeline('text-classification', model='nlmaldonadog/clasificador-rotten-tomatoes-xlnet-base-cased')
# def predict(text):
# prediction = classifier(text)
# return prediction[0]
# iface = gr.Interface(fn=predict, inputs=[gr.Textbox(placeholder='Escribe aquí...')], outputs="text")
# iface.launch(share=True)
from huggingface_hub import from_pretrained_fastai
import gradio as gr
from fastai.text.all import *
# Cargar el primer modelo
repo_id1 = "nlmaldonadog/AWD_LSTM_P7"
learner1 = from_pretrained_fastai(repo_id1)
labels1 = learner1.dls.vocab
def predict1(text):
pred,pred_idx,probs = learner1.predict(text)
return str({labels1[i]: float(probs[i]) for i in range(len(labels1))})
texto = gr.Textbox(placeholder='Escribe aquí...')
# Creamos las interfaces y las lanzamos.
gr.Interface(fn=predict1, inputs=[texto], outputs="text").launch(share=True)