mrfakename commited on
Commit
d344789
1 Parent(s): 7927ab2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -476,10 +476,21 @@ with gr.Blocks() as leaderboard:
476
  def predict_and_update(router, text, model, gr_update, api_name):
477
  prediction = router.predict(text, AVAILABLE_MODELS[model], api_name)
478
  gr_update(visible=True, value=prediction)
 
479
 
480
  def predict_and_update_both(router, text, mdl1, mdl2, gr_update1, gr_update2):
481
- thread1 = threading.Thread(target=predict_and_update, args=(router, text, mdl1, gr_update1, "/synthesize"))
482
- thread2 = threading.Thread(target=predict_and_update, args=(router, text, mdl2, gr_update2, "/synthesize"))
 
 
 
 
 
 
 
 
 
 
483
 
484
  thread1.start()
485
  thread2.start()
@@ -487,8 +498,7 @@ def predict_and_update_both(router, text, mdl1, mdl2, gr_update1, gr_update2):
487
  thread1.join() # Wait for thread1 to finish
488
  thread2.join() # Wait for thread2 to finish
489
 
490
- return thread1.predicted_value, thread2.predicted_value
491
-
492
  ############
493
  # 2x speedup (hopefully)
494
  ############
 
476
  def predict_and_update(router, text, model, gr_update, api_name):
477
  prediction = router.predict(text, AVAILABLE_MODELS[model], api_name)
478
  gr_update(visible=True, value=prediction)
479
+ return prediction
480
 
481
  def predict_and_update_both(router, text, mdl1, mdl2, gr_update1, gr_update2):
482
+ result1, result2 = [None, None] # Placeholder for storing predictions
483
+
484
+ def thread_func1():
485
+ nonlocal result1
486
+ result1 = predict_and_update(router, text, mdl1, gr_update1, "/synthesize")
487
+
488
+ def thread_func2():
489
+ nonlocal result2
490
+ result2 = predict_and_update(router, text, mdl2, gr_update2, "/synthesize")
491
+
492
+ thread1 = threading.Thread(target=thread_func1)
493
+ thread2 = threading.Thread(target=thread_func2)
494
 
495
  thread1.start()
496
  thread2.start()
 
498
  thread1.join() # Wait for thread1 to finish
499
  thread2.join() # Wait for thread2 to finish
500
 
501
+ return result1, result2
 
502
  ############
503
  # 2x speedup (hopefully)
504
  ############