Eli181927 commited on
Commit
8dcf078
·
verified ·
1 Parent(s): 9617586

Upload app.py

Browse files
Files changed (1) hide show
  1. 2.CNN/app.py +15 -3
2.CNN/app.py CHANGED
@@ -544,7 +544,7 @@ def predict_number(left_canvas, right_canvas, stroke_scale, auto_balance):
544
  return pred, prob_rows, (preview * 255).astype(np.uint8), mean_diff, json.dumps(diagnostics, indent=2)
545
 
546
 
547
- with gr.Blocks(queue=True) as demo:
548
  gr.Markdown(
549
  """
550
  # Elliot's MNIST-100 Classifier
@@ -617,10 +617,22 @@ with gr.Blocks(queue=True) as demo:
617
 
618
  if __name__ == "__main__":
619
  space_env = os.getenv("SPACE_ID")
 
 
 
 
 
 
 
 
 
 
 
 
620
  if space_env:
621
- demo.queue(concurrency_count=1).launch(show_api=False)
622
  else:
623
- demo.queue(concurrency_count=1).launch(server_name="0.0.0.0", share=True, show_api=False)
624
  def _disable_gradio_api_schema(*_args, **_kwargs):
625
  """Work around Gradio schema bug on Python 3.13 by returning empty metadata."""
626
  return {}
 
544
  return pred, prob_rows, (preview * 255).astype(np.uint8), mean_diff, json.dumps(diagnostics, indent=2)
545
 
546
 
547
+ with gr.Blocks() as demo:
548
  gr.Markdown(
549
  """
550
  # Elliot's MNIST-100 Classifier
 
617
 
618
  if __name__ == "__main__":
619
  space_env = os.getenv("SPACE_ID")
620
+
621
+ def _queue_app(blocks):
622
+ try:
623
+ return blocks.queue(concurrency_count=1)
624
+ except TypeError:
625
+ # Older Gradio versions don't support the argument
626
+ try:
627
+ return blocks.queue()
628
+ except Exception:
629
+ return blocks
630
+
631
+ app_to_launch = _queue_app(demo)
632
  if space_env:
633
+ app_to_launch.launch(show_api=False)
634
  else:
635
+ app_to_launch.launch(server_name="0.0.0.0", share=True, show_api=False)
636
  def _disable_gradio_api_schema(*_args, **_kwargs):
637
  """Work around Gradio schema bug on Python 3.13 by returning empty metadata."""
638
  return {}