yejimene commited on
Commit
575ffd8
·
verified ·
1 Parent(s): e3292db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -1,10 +1,15 @@
1
- from transformers import pipeline
2
  import gradio as gr
3
 
4
- classifier = pipeline("text-classification", model="yejimene/clasificadorTexto")
 
5
 
6
  def predict(text):
7
- result = classifier(text)[0]
8
- return {result['label']: result['score']}
9
-
10
- gr.Interface(fn=predict, inputs="text", outputs=gr.outputs.Label()).launch(share=False)
 
 
 
 
 
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()