taskswithcode commited on
Commit
1e9f08c
1 Parent(s): 43f46f9

Compute time display fix

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -5,6 +5,7 @@ from io import StringIO
5
  import pdb
6
  import json
7
  from twc_embeddings import HFModel,SimCSEModel,SGPTModel
 
8
 
9
 
10
  MAX_INPUT = 100
@@ -151,7 +152,7 @@ def construct_model_info_for_display():
151
  if (node["mark"] == True):
152
  markdown_str += f"<div style=\"font-size:16px; color: #5f5f5f; text-align: left\">&nbsp;•&nbsp;Model:&nbsp;<a href=\'{node['paper_url']}\' target='_blank'>{node['name']}</a><br/>&nbsp;&nbsp;&nbsp;&nbsp;Code released by:&nbsp;<a href=\'{node['orig_author_url']}\' target='_blank'>{node['orig_author']}</a><br/>&nbsp;&nbsp;&nbsp;&nbsp;Model info:&nbsp;<a href=\'{node['sota_info']['sota_link']}\' target='_blank'>{node['sota_info']['task']}</a></div>"
153
  if ("Note" in node):
154
- markdown_str += f"<div style=\"font-size:16px; color: #dd1515; text-align: left\">&nbsp;&nbsp;&nbsp;&nbsp;{node['Note']}<a href=\'{node['alt_url']}\' target='_blank'>link</a></div>"
155
  markdown_str += "<div style=\"font-size:16px; color: #5f5f5f; text-align: left\"><br/></div>"
156
 
157
  markdown_str += "<div style=\"font-size:12px; color: #9f9f9f; text-align: left\"><b>Note:</b><br/>•&nbsp;Uploaded files are loaded into non-persistent memory for the duration of the computation. They are not saved</div>"
@@ -299,7 +300,8 @@ def main():
299
  results = run_test(selected_model,sentences,display_area,main_index - 1,(uploaded_file is not None))
300
  display_area.empty()
301
  with display_area.container():
302
- response_info = f"Response time - {time.time() - start:.2f} secs for {len(sentences)} sentences"
 
303
  display_results(sentences,main_index - 1,results,response_info)
304
  #st.json(results)
305
  st.download_button(
 
5
  import pdb
6
  import json
7
  from twc_embeddings import HFModel,SimCSEModel,SGPTModel
8
+ import torch
9
 
10
 
11
  MAX_INPUT = 100
 
152
  if (node["mark"] == True):
153
  markdown_str += f"<div style=\"font-size:16px; color: #5f5f5f; text-align: left\">&nbsp;•&nbsp;Model:&nbsp;<a href=\'{node['paper_url']}\' target='_blank'>{node['name']}</a><br/>&nbsp;&nbsp;&nbsp;&nbsp;Code released by:&nbsp;<a href=\'{node['orig_author_url']}\' target='_blank'>{node['orig_author']}</a><br/>&nbsp;&nbsp;&nbsp;&nbsp;Model info:&nbsp;<a href=\'{node['sota_info']['sota_link']}\' target='_blank'>{node['sota_info']['task']}</a></div>"
154
  if ("Note" in node):
155
+ markdown_str += f"<div style=\"font-size:16px; color: #a91212; text-align: left\">&nbsp;&nbsp;&nbsp;&nbsp;{node['Note']}<a href=\'{node['alt_url']}\' target='_blank'>link</a></div>"
156
  markdown_str += "<div style=\"font-size:16px; color: #5f5f5f; text-align: left\"><br/></div>"
157
 
158
  markdown_str += "<div style=\"font-size:12px; color: #9f9f9f; text-align: left\"><b>Note:</b><br/>•&nbsp;Uploaded files are loaded into non-persistent memory for the duration of the computation. They are not saved</div>"
 
300
  results = run_test(selected_model,sentences,display_area,main_index - 1,(uploaded_file is not None))
301
  display_area.empty()
302
  with display_area.container():
303
+ device = 'gpu' if torch.cuda.is_available() else 'cpu'
304
+ response_info = f"Computation time on {device}: {time.time() - start:.2f} secs for {len(sentences)} sentences"
305
  display_results(sentences,main_index - 1,results,response_info)
306
  #st.json(results)
307
  st.download_button(