ethanrom commited on
Commit
c9a75cb
1 Parent(s): 6608ecd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -22,7 +22,9 @@ def predict_sentiment(text_input, model_selection):
22
  predicted_class = int(logits.argmax())
23
  inference_time = end_time - start_time
24
  model_size = model.num_parameters()
25
- return candidate_labels[predicted_class], inference_time, model_size
 
 
26
  else:
27
  start_time = time.time()
28
  result = pretrained_model(text_input, candidate_labels)
@@ -30,7 +32,9 @@ def predict_sentiment(text_input, model_selection):
30
  predicted_class = result["labels"][0]
31
  inference_time = end_time - start_time
32
  model_size = pretrained_tokenizer.model_max_length + pretrained_model.model.num_parameters()
33
- return predicted_class, inference_time, model_size
 
 
34
 
35
  inputs = [
36
  gr.inputs.Textbox("Enter text"),
@@ -41,6 +45,7 @@ outputs = [
41
  gr.outputs.Textbox(label="Predicted Sentiment"),
42
  gr.outputs.Textbox(label="Inference Time (s)"),
43
  gr.outputs.Textbox(label="Model Size (params)"),
 
44
  ]
45
 
46
  gr.Interface(fn=predict_sentiment, inputs=inputs, outputs=outputs, title="Sentiment Analysis", description="roberta-large-mnli fine tuned with poem_sentiment dataset for sentiment analysis", examples=[
 
22
  predicted_class = int(logits.argmax())
23
  inference_time = end_time - start_time
24
  model_size = model.num_parameters()
25
+ architecture = model.config.architectures[0]
26
+ #batch_size = inputs['input_ids'].shape[0]
27
+ return candidate_labels[predicted_class], inference_time, model_size, architecture
28
  else:
29
  start_time = time.time()
30
  result = pretrained_model(text_input, candidate_labels)
 
32
  predicted_class = result["labels"][0]
33
  inference_time = end_time - start_time
34
  model_size = pretrained_tokenizer.model_max_length + pretrained_model.model.num_parameters()
35
+ architecture = pretrained_model.model.config.architectures[0]
36
+ #batch_size = 1
37
+ return predicted_class, inference_time, model_size, architecture
38
 
39
  inputs = [
40
  gr.inputs.Textbox("Enter text"),
 
45
  gr.outputs.Textbox(label="Predicted Sentiment"),
46
  gr.outputs.Textbox(label="Inference Time (s)"),
47
  gr.outputs.Textbox(label="Model Size (params)"),
48
+ gr.outputs.Textbox(label="Architecture"),
49
  ]
50
 
51
  gr.Interface(fn=predict_sentiment, inputs=inputs, outputs=outputs, title="Sentiment Analysis", description="roberta-large-mnli fine tuned with poem_sentiment dataset for sentiment analysis", examples=[