huzey commited on
Commit
645651e
1 Parent(s): 6dceac4

update deploy

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -2,9 +2,15 @@
2
  # %%
3
  import os
4
  USE_HUGGINGFACE_ZEROGPU = os.getenv("USE_HUGGINGFACE_ZEROGPU", "False").lower() in ["true", "1", "yes"]
 
5
  #%%
6
  if USE_HUGGINGFACE_ZEROGPU: # huggingface ZeroGPU, dynamic GPU allocation
7
- import spaces
 
 
 
 
 
8
  BATCH_SIZE = 4
9
  else: # run on local machine
10
  BATCH_SIZE = 1
@@ -900,15 +906,14 @@ with demo:
900
 
901
 
902
 
903
- if USE_HUGGINGFACE_ZEROGPU:
904
  from ncut_pytorch.backbone import download_all_models
905
  threading.Thread(target=download_all_models).start()
906
  from ncut_pytorch.backbone_text import download_all_models
907
  threading.Thread(target=download_all_models).start()
908
 
909
  threading.Thread(target=download_all_datasets).start()
910
- demo.launch()
911
- else:
912
- demo.launch(share=True)
913
 
914
  # %%
 
2
  # %%
3
  import os
4
  USE_HUGGINGFACE_ZEROGPU = os.getenv("USE_HUGGINGFACE_ZEROGPU", "False").lower() in ["true", "1", "yes"]
5
+ DOWNLOAD_ALL_MODELS_DATASETS = os.getenv("DOWNLOAD_ALL_MODELS_DATASETS", "False").lower() in ["true", "1", "yes"]
6
  #%%
7
  if USE_HUGGINGFACE_ZEROGPU: # huggingface ZeroGPU, dynamic GPU allocation
8
+ try:
9
+ import spaces
10
+ except:
11
+ USE_HUGGINGFACE_ZEROGPU = False
12
+
13
+ if USE_HUGGINGFACE_ZEROGPU:
14
  BATCH_SIZE = 4
15
  else: # run on local machine
16
  BATCH_SIZE = 1
 
906
 
907
 
908
 
909
+ if DOWNLOAD_ALL_MODELS_DATASETS:
910
  from ncut_pytorch.backbone import download_all_models
911
  threading.Thread(target=download_all_models).start()
912
  from ncut_pytorch.backbone_text import download_all_models
913
  threading.Thread(target=download_all_models).start()
914
 
915
  threading.Thread(target=download_all_datasets).start()
916
+
917
+ demo.launch(share=True)
 
918
 
919
  # %%