Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
from huggingface_hub import from_pretrained_fastai
|
2 |
import gradio as gr
|
3 |
-
from fastai.text.all import *
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
learner1 = from_pretrained_fastai(repo_id1)
|
8 |
-
labels1 = learner1.dls.vocab
|
9 |
|
10 |
-
def
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
# Creamos la interfaz y la lanzamos.
|
17 |
-
gr.Interface(fn=predict1, inputs=texto, outputs=gr.outputs.Label()).launch(share=False)
|
|
|
|
|
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 |
+
score = int(round(prediction[0]['score'] * 100))
|
9 |
+
|
10 |
+
if prediction[0]['label'] == "LABEL_0":
|
11 |
+
output = f"Negative sentiment with a confidence level of {score}%."
|
12 |
+
else:
|
13 |
+
output = f"Positive sentiment with a confidence level of {score}%."
|
14 |
+
return output
|
15 |
|
16 |
+
iface = gr.Interface(fn=predict, inputs=[gr.Textbox(placeholder='Escribe aquí...')], outputs="text")
|
17 |
+
iface.launch(share=True)
|
|
|
|