Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
| 1 |
-
from
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
def predict(text):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import from_pretrained_fastai
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
repo_id = "yejimene/clasificadorTexto"
|
| 5 |
+
learner = from_pretrained_fastai(repo_id)
|
| 6 |
|
| 7 |
def predict(text):
|
| 8 |
+
pred,pred_idx,probs = learner.predict(text)
|
| 9 |
+
if pred == "0":
|
| 10 |
+
return "NEGATIVE"
|
| 11 |
+
elif pred == "1":
|
| 12 |
+
return "POSITIVE"
|
| 13 |
+
else:
|
| 14 |
+
return "error"
|
| 15 |
+
gr.Interface(fn=predict, inputs="text", outputs="label", examples=["This movie was terrible and boring.","I loved this movie, it was amazing!"]).launch()
|