huzey commited on
Commit
96f34e8
1 Parent(s): 645651e

update deploy

Browse files
Files changed (1) hide show
  1. app_text.py +8 -7
app_text.py CHANGED
@@ -1,12 +1,13 @@
1
  # %%
2
- USE_HUGGINGFACE_SPACE = True
3
-
4
- if USE_HUGGINGFACE_SPACE: # huggingface ZeroGPU, dynamic GPU allocation
 
5
  try:
6
  import spaces
7
- except ImportError:
8
- USE_HUGGINGFACE_SPACE = False # run on local machine
9
-
10
  import gradio as gr
11
 
12
  import torch
@@ -213,7 +214,7 @@ def _ncut_run(*args, **kwargs):
213
  torch.cuda.empty_cache()
214
  return None, "Error: " + str(e)
215
 
216
- if USE_HUGGINGFACE_SPACE:
217
  @spaces.GPU(duration=30)
218
  def __ncut_run(*args, **kwargs):
219
  return _ncut_run(*args, **kwargs)
 
1
  # %%
2
+ import os
3
+ USE_HUGGINGFACE_ZEROGPU = os.getenv("USE_HUGGINGFACE_ZEROGPU", "False").lower() in ["true", "1", "yes"]
4
+ #%%
5
+ if USE_HUGGINGFACE_ZEROGPU: # huggingface ZeroGPU, dynamic GPU allocation
6
  try:
7
  import spaces
8
+ except:
9
+ USE_HUGGINGFACE_ZEROGPU = False
10
+
11
  import gradio as gr
12
 
13
  import torch
 
214
  torch.cuda.empty_cache()
215
  return None, "Error: " + str(e)
216
 
217
+ if USE_HUGGINGFACE_ZEROGPU:
218
  @spaces.GPU(duration=30)
219
  def __ncut_run(*args, **kwargs):
220
  return _ncut_run(*args, **kwargs)