Julien Simon commited on
Commit
2408ada
1 Parent(s): e930d0c

Fix output

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -4,10 +4,12 @@ from transformers import pipeline
4
  classifier = pipeline("text-classification", model="juliensimon/distilbert-amazon-shoe-reviews")
5
 
6
  def predict(review):
7
- prediction = classifier(review)
8
- stars = (int)(prediction['label'].split('_')[1])
9
- score = prediction['score']
10
- return "{} {:.0f}%".format("\U00002B50"*stars, score)
 
 
11
 
12
  iface = gr.Interface(fn=predict, inputs="text", outputs="text")
13
- iface.launch()
 
4
  classifier = pipeline("text-classification", model="juliensimon/distilbert-amazon-shoe-reviews")
5
 
6
  def predict(review):
7
+ prediction = classifier(review)
8
+ print(prediction)
9
+ stars = prediction[0]['label']
10
+ stars = (int)(stars.split('_')[1])+1
11
+ score = 100*prediction[0]['score']
12
+ return "{} {:.0f}%".format("\U00002B50"*stars, score)
13
 
14
  iface = gr.Interface(fn=predict, inputs="text", outputs="text")
15
+ iface.launch()