dreamboat26 commited on
Commit
bffc6b5
·
verified ·
1 Parent(s): 57ba8e7

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +15 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
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()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch
2
+ transformers