CK42 commited on
Commit
9f35afb
1 Parent(s): b2f58d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -14
app.py CHANGED
@@ -11,7 +11,8 @@ from huggingface_hub.repocard import metadata_load
11
  app = gr.Blocks()
12
 
13
  model_id_1 = "nlptown/bert-base-multilingual-uncased-sentiment"
14
- model_id_2 = "juliensimon/distilbert-amazon-shoe-reviews"
 
15
 
16
  def load_agent(model_id):
17
  """
@@ -19,11 +20,9 @@ def load_agent(model_id):
19
  """
20
  # Load the metrics
21
  metadata = get_metadata(model_id)
22
-
23
  # get predictions
24
  predictions = predict(model_id)
25
 
26
-
27
  return model_id, predictions
28
 
29
 
@@ -47,12 +46,11 @@ def get_prediction(model_id):
47
 
48
  def predict(review):
49
  prediction = classifier(review)
50
- print(prediction)
51
- # stars = prediction[0]['label']
52
- # stars = (int)(stars.split('_')[1])+1
53
- # score = 100*prediction[0]['score']
54
- # return "{} {:.0f}%".format("\U00002B50"*stars, score)
55
- return prediction
56
  return predict
57
 
58
  with app:
@@ -79,20 +77,32 @@ with app:
79
  btn1 = gr.Button("Predict for Model 1")
80
  with gr.Row():
81
  out_1 = gr.Textbox(label="Prediction for Model 1")
82
-
83
- # classifier = pipeline("text-classification", model)
84
  btn1.click(fn=get_prediction(model_id_1), inputs=inp_1, outputs=out_1)
85
 
86
  gr.Markdown(
87
  """
88
- Model 2 = juliensimon/distilbert-amazon-shoe-reviews
89
  """)
90
 
91
  with gr.Row():
92
  btn2 = gr.Button("Predict for Model 2")
93
  with gr.Row():
94
- out_2 = gr.Textbox(label="Prediction for Model 2")
95
- classifier = pipeline("text-classification", model=model_id_2)
96
  btn2.click(fn=get_prediction(model_id_2), inputs=inp_1, outputs=out_2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  app.launch()
 
11
  app = gr.Blocks()
12
 
13
  model_id_1 = "nlptown/bert-base-multilingual-uncased-sentiment"
14
+ model_id_2 = "microsoft/deberta-base"
15
+ model_id_3 = "juliensimon/distilbert-amazon-shoe-reviews"
16
 
17
  def load_agent(model_id):
18
  """
 
20
  """
21
  # Load the metrics
22
  metadata = get_metadata(model_id)
 
23
  # get predictions
24
  predictions = predict(model_id)
25
 
 
26
  return model_id, predictions
27
 
28
 
 
46
 
47
  def predict(review):
48
  prediction = classifier(review)
49
+ predictions = []
50
+ for p in prediction:
51
+ new_pred = print(p)
52
+ predictions.append(new_pred)
53
+ return predictions
 
54
  return predict
55
 
56
  with app:
 
77
  btn1 = gr.Button("Predict for Model 1")
78
  with gr.Row():
79
  out_1 = gr.Textbox(label="Prediction for Model 1")
 
 
80
  btn1.click(fn=get_prediction(model_id_1), inputs=inp_1, outputs=out_1)
81
 
82
  gr.Markdown(
83
  """
84
+ Model 2 = microsoft/deberta-base
85
  """)
86
 
87
  with gr.Row():
88
  btn2 = gr.Button("Predict for Model 2")
89
  with gr.Row():
90
+ out_2 = gr.Textbox(label="Prediction for Model 2")
 
91
  btn2.click(fn=get_prediction(model_id_2), inputs=inp_1, outputs=out_2)
92
+
93
+ gr.Markdown(
94
+ """
95
+ Model 3 = juliensimon/distilbert-amazon-shoe-reviews
96
+ """)
97
+
98
+ with gr.Row():
99
+ btn3 = gr.Button("Predict for Model 3")
100
+ with gr.Row():
101
+ out_3 = gr.Textbox(label="Prediction for Model 3")
102
+ classifier = pipeline("text-classification", model=model_id_3)
103
+ btn3.click(fn=get_prediction(model_id_2), inputs=inp_1, outputs=out_3)
104
+
105
+
106
+
107
 
108
  app.launch()