CK42 commited on
Commit
19964c7
1 Parent(s): 48193db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -54,6 +54,15 @@ def get_metadata(model_id):
54
  except requests.exceptions.HTTPError:
55
  return None
56
 
 
 
 
 
 
 
 
 
 
57
 
58
  with app:
59
  gr.Markdown(
@@ -70,7 +79,7 @@ with app:
70
  inp = gr.Textbox(placeholder="The customer service was satisfactory.")
71
  out = gr.Textbox()
72
  btn = gr.Button("Run")
73
- btn.click(fn=update, inputs=inp, outputs=out)
74
 
75
  with gr.Row():
76
  app_button = gr.Button("Compare models")
 
54
  except requests.exceptions.HTTPError:
55
  return None
56
 
57
+ classifier = pipeline("text-classification", model="juliensimon/distilbert-amazon-shoe-reviews")
58
+
59
+ def predict(review):
60
+ prediction = classifier(review)
61
+ print(prediction)
62
+ stars = prediction[0]['label']
63
+ stars = (int)(stars.split('_')[1])+1
64
+ score = 100*prediction[0]['score']
65
+ return "{} {:.0f}%".format("\U00002B50"*stars, score)
66
 
67
  with app:
68
  gr.Markdown(
 
79
  inp = gr.Textbox(placeholder="The customer service was satisfactory.")
80
  out = gr.Textbox()
81
  btn = gr.Button("Run")
82
+ btn.click(fn=predict, inputs=inp, outputs=out)
83
 
84
  with gr.Row():
85
  app_button = gr.Button("Compare models")