lunadebruyne commited on
Commit
658bd4a
·
1 Parent(s): b1b7eec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -152,10 +152,12 @@ def what_happened2(file_object, option_list):
152
  output5 = "This option was selected."
153
  return [output1, output2, output3, output4, output5]
154
 
155
- def inference_sentence(text):
 
156
  tokenizer = AutoTokenizer.from_pretrained(inference_modelpath)
157
  model = AutoModelForSequenceClassification.from_pretrained(inference_modelpath)
158
- inputs = tokenizer(text, return_tensors="pt")
 
159
  with torch.no_grad(): # run model
160
  logits = model(**inputs).logits
161
  predicted_class_id = logits.argmax().item()
@@ -208,4 +210,4 @@ iface2 = gr.Interface(
208
 
209
  iface = gr.TabbedInterface([iface_sentence, iface2], ["Sentence", "Dataset"])
210
 
211
- iface.launch()
 
152
  output5 = "This option was selected."
153
  return [output1, output2, output3, output4, output5]
154
 
155
+ def inference_sentence(text, progress=gr.Progress()):
156
+ progress(0, desc="Starting...")
157
  tokenizer = AutoTokenizer.from_pretrained(inference_modelpath)
158
  model = AutoModelForSequenceClassification.from_pretrained(inference_modelpath)
159
+ for text in tqdm([text]):
160
+ inputs = tokenizer(text, return_tensors="pt")
161
  with torch.no_grad(): # run model
162
  logits = model(**inputs).logits
163
  predicted_class_id = logits.argmax().item()
 
210
 
211
  iface = gr.TabbedInterface([iface_sentence, iface2], ["Sentence", "Dataset"])
212
 
213
+ iface.queue().launch()