nlmaldonadog commited on
Commit
5c46664
·
verified ·
1 Parent(s): 657ffcb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -23
app.py CHANGED
@@ -1,28 +1,14 @@
1
- # import gradio as gr
2
-
3
- # from transformers import pipeline
4
- # classifier = pipeline('text-classification', model='nlmaldonadog/clasificador-rotten-tomatoes-xlnet-base-cased')
5
-
6
- # def predict(text):
7
- # prediction = classifier(text)
8
- # return prediction[0]
9
-
10
- # iface = gr.Interface(fn=predict, inputs=[gr.Textbox(placeholder='Escribe aquí...')], outputs="text")
11
- # iface.launch(share=True)
12
- from huggingface_hub import from_pretrained_fastai
13
  import gradio as gr
14
- from fastai.text.all import *
15
 
16
- # Cargar el primer modelo
17
- repo_id1 = "nlmaldonadog/AWD_LSTM_P7"
18
- learner1 = from_pretrained_fastai(repo_id1)
19
- labels1 = learner1.dls.vocab
20
 
21
- def predict1(text):
22
- pred,pred_idx,probs = learner1.predict(text)
23
- return str({labels1[i]: float(probs[i]) for i in range(len(labels1))})
24
 
25
- texto = gr.Textbox(placeholder='Escribe aquí...')
 
 
 
26
 
27
- # Creamos las interfaces y las lanzamos.
28
- gr.Interface(fn=predict1, inputs=[texto], outputs="text").launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
 
2
 
3
+ from transformers import pipeline
 
 
 
4
 
5
+ classifier3 = pipeline('text-classification', model='nlmaldonadog/clasificador-rotten-tomatoes-bert-base-uncased')
6
+ classifier4 = pipeline('text-classification', model='nlmaldonadog/clasificador-rotten-tomatoes-xlnet-base-cased')
 
7
 
8
+ def predict(text):
9
+ prediction3 = classifier3(text)
10
+ prediction4 = classifier4(text)
11
+ return DatasetDict({'bert-base-uncased': prediction3, 'xlnet-base-cased': prediction4})
12
 
13
+ iface = gr.Interface(fn=predict, inputs=[gr.Textbox(placeholder='Escribe aquí...')], outputs="text")
14
+ iface.launch(share=True)