Update app.py
Browse files
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 |
-
|
17 |
-
repo_id1 = "nlmaldonadog/AWD_LSTM_P7"
|
18 |
-
learner1 = from_pretrained_fastai(repo_id1)
|
19 |
-
labels1 = learner1.dls.vocab
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
return str({labels1[i]: float(probs[i]) for i in range(len(labels1))})
|
24 |
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|