huzey commited on
Commit
27a746c
1 Parent(s): 6770cdc

handle gpu quota

Browse files
Files changed (1) hide show
  1. app.py +31 -25
app.py CHANGED
@@ -961,35 +961,41 @@ def run_fn(
961
  }
962
  # print(kwargs)
963
 
964
- if old_school_ncut:
965
- return super_duper_long_run(model, images, **kwargs)
966
-
967
- if is_lisa:
968
- return super_duper_long_run(model, images, **kwargs)
969
 
970
- num_images = len(images)
971
- if num_images >= 100:
972
- return super_duper_long_run(model, images, **kwargs)
973
- if 'diffusion' in model_name.lower():
974
- return super_duper_long_run(model, images, **kwargs)
975
- if recursion:
976
- return longer_run(model, images, **kwargs)
977
- if num_images >= 50:
978
- return longer_run(model, images, **kwargs)
979
- if old_school_ncut:
980
- return longer_run(model, images, **kwargs)
981
- if num_images >= 10:
982
- return long_run(model, images, **kwargs)
983
- if embedding_method == "UMAP":
984
- if perplexity >= 250 or num_sample_tsne >= 500:
985
  return longer_run(model, images, **kwargs)
986
- return long_run(model, images, **kwargs)
987
- if embedding_method == "t-SNE":
988
- if perplexity >= 250 or num_sample_tsne >= 500:
 
 
 
 
 
 
989
  return long_run(model, images, **kwargs)
 
 
 
 
 
990
  return quick_run(model, images, **kwargs)
991
 
992
- return quick_run(model, images, **kwargs)
 
 
993
 
994
 
995
 
@@ -1824,7 +1830,7 @@ with demo:
1824
  with gr.Column():
1825
  gr.Markdown("##### This demo is for `ncut-pytorch`, [Documentation](https://ncut-pytorch.readthedocs.io/) ")
1826
  with gr.Column():
1827
- gr.Markdown("###### Running out of GPU? Try [Demo](https://ncut-pytorch.readthedocs.io/en/latest/demo/) hosted at UPenn")
1828
 
1829
  # for local development
1830
  if os.path.exists("/hf_token.txt"):
 
961
  }
962
  # print(kwargs)
963
 
964
+ try:
 
 
 
 
965
 
966
+ if old_school_ncut:
967
+ return super_duper_long_run(model, images, **kwargs)
968
+
969
+ if is_lisa:
970
+ return super_duper_long_run(model, images, **kwargs)
971
+
972
+ num_images = len(images)
973
+ if num_images >= 100:
974
+ return super_duper_long_run(model, images, **kwargs)
975
+ if 'diffusion' in model_name.lower():
976
+ return super_duper_long_run(model, images, **kwargs)
977
+ if recursion:
 
 
 
978
  return longer_run(model, images, **kwargs)
979
+ if num_images >= 50:
980
+ return longer_run(model, images, **kwargs)
981
+ if old_school_ncut:
982
+ return longer_run(model, images, **kwargs)
983
+ if num_images >= 10:
984
+ return long_run(model, images, **kwargs)
985
+ if embedding_method == "UMAP":
986
+ if perplexity >= 250 or num_sample_tsne >= 500:
987
+ return longer_run(model, images, **kwargs)
988
  return long_run(model, images, **kwargs)
989
+ if embedding_method == "t-SNE":
990
+ if perplexity >= 250 or num_sample_tsne >= 500:
991
+ return long_run(model, images, **kwargs)
992
+ return quick_run(model, images, **kwargs)
993
+
994
  return quick_run(model, images, **kwargs)
995
 
996
+ except Exception as e:
997
+ gr.Error(str(e))
998
+ gr.Info("Running out of GPU Quota? Try this demo hosted at UPenn.\n https://ncut-pytorch.readthedocs.io/en/latest/demo/")
999
 
1000
 
1001
 
 
1830
  with gr.Column():
1831
  gr.Markdown("##### This demo is for `ncut-pytorch`, [Documentation](https://ncut-pytorch.readthedocs.io/) ")
1832
  with gr.Column():
1833
+ gr.Markdown("###### Running out of GPU Quota? Try [Demo](https://ncut-pytorch.readthedocs.io/en/latest/demo/) hosted at UPenn")
1834
 
1835
  # for local development
1836
  if os.path.exists("/hf_token.txt"):