File size: 948 Bytes
5c36d1e
 
 
 
 
 
 
 
 
 
 
0b70cc6
18e9487
0b70cc6
18e9487
0b70cc6
 
 
 
18e9487
0b70cc6
 
816702a
18e9487
eb5dbe1
0b70cc6
 
8aa3570
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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)