CK42 commited on
Commit
29d2c40
1 Parent(s): 2c98611

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -81
app.py CHANGED
@@ -17,32 +17,6 @@ model_id_4 = "lordtt13/emo-mobilebert"
17
  model_id_5 = "juliensimon/reviews-sentiment-analysis"
18
 
19
 
20
- def load_agent(model_id):
21
- """
22
- This function load the agent's results
23
- """
24
- # Load the metrics
25
- metadata = get_metadata(model_id)
26
- # get predictions
27
- predictions = predict(model_id)
28
-
29
- return model_id, predictions
30
-
31
-
32
- def get_metadata(model_id):
33
- """
34
- Get the metadata of the model repo
35
- :param model_id:
36
- :return: metadata
37
- """
38
- try:
39
- readme_path = hf_hub_download(model_id, filename="README.md")
40
- metadata = metadata_load(readme_path)
41
- print(metadata)
42
- return metadata
43
- except requests.exceptions.HTTPError:
44
- return None
45
-
46
  def get_prediction(model_id):
47
 
48
  classifier = pipeline("text-classification", model=model_id, return_all_scores=True)
@@ -68,61 +42,17 @@ with app:
68
  """
69
  **Model Predictions**
70
  """)
71
-
72
- gr.Markdown(
73
- """
74
- Model 1 = nlptown/bert-base-multilingual-uncased-sentiment
75
- """)
76
-
77
- with gr.Row():
78
- btn1 = gr.Button("Predict - Model 1")
79
- with gr.Row():
80
- out_1 = gr.Textbox(label="Predictions for Model 1")
81
- btn1.click(fn=get_prediction(model_id_1), inputs=inp_1, outputs=out_1)
82
-
83
- gr.Markdown(
84
- """
85
- Model 2 = microsoft/deberta-base
86
- """)
87
-
88
- with gr.Row():
89
- btn2 = gr.Button("Predict - Model 2")
90
- with gr.Row():
91
- out_2 = gr.Textbox(label="Predictions for Model 2")
92
- btn2.click(fn=get_prediction(model_id_2), inputs=inp_1, outputs=out_2)
93
-
94
- gr.Markdown(
95
- """
96
- Model 3 = distilbert-base-uncased-finetuned-sst-2-english"
97
- """)
98
-
99
- with gr.Row():
100
- btn3 = gr.Button("Predict - Model 3")
101
- with gr.Row():
102
- out_3 = gr.Textbox(label="Predictions for Model 3")
103
- btn3.click(fn=get_prediction(model_id_3), inputs=inp_1, outputs=out_3)
104
-
105
- gr.Markdown(
106
- """
107
- Model 4 = lordtt13/emo-mobilebert
108
- """)
109
-
110
- with gr.Row():
111
- btn4 = gr.Button("Predict - Model 4")
112
  with gr.Row():
113
- out_4 = gr.Textbox(label="Predictions for Model 4")
114
- btn4.click(fn=get_prediction(model_id_4), inputs=inp_1, outputs=out_4)
115
-
116
- gr.Markdown(
117
- """
118
- Model 5 = juliensimon/reviews-sentiment-analysis
119
- """)
120
-
121
- with gr.Row():
122
- btn5 = gr.Button("Predict - Model 5")
123
- with gr.Row():
124
- out_5 = gr.Textbox(label="Predictions for Model 5")
125
- btn5.click(fn=get_prediction(model_id_5), inputs=inp_1, outputs=out_5)
126
-
127
 
128
  app.launch()
 
17
  model_id_5 = "juliensimon/reviews-sentiment-analysis"
18
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  def get_prediction(model_id):
21
 
22
  classifier = pipeline("text-classification", model=model_id, return_all_scores=True)
 
42
  """
43
  **Model Predictions**
44
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  with gr.Row():
46
+ with gr.Column():
47
+ text1 = gr.Textbox(label="Model 1 = nlptown/bert-base-multilingual-uncased-sentiment")
48
+ btn1 = gr.Button("Predict - Model 1")
49
+ text2 = gr.Textbox(label="Model 2 = microsoft/deberta-base")
50
+ btn2 = gr.Button("Predict - Model 2")
51
+ with gr.Column():
52
+ out_1 = gr.Textbox(label="Predictions for Model 1")
53
+ out_2 = gr.Textbox(label="Predictions for Model 2")
54
+ btn1.click(fn=get_prediction(model_id_1), inputs=inp_1, outputs=out_1)
55
+ btn2.click(fn=get_prediction(model_id_2), inputs=inp_1, outputs=out_2)
56
+
 
 
 
57
 
58
  app.launch()