masapasa commited on
Commit
62c5688
1 Parent(s): 0bac85e

Create new file

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