huzey commited on
Commit
3e06034
1 Parent(s): 00dc973
Files changed (2) hide show
  1. app.py +6 -6
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,13 +1,13 @@
1
  # Author: Huzheng Yang
2
  # %%
3
- HUGGINGFACE_SPACE = True
4
  BATCH_SIZE = 4
5
 
6
- if HUGGINGFACE_SPACE: # huggingface ZeroGPU, dynamic GPU allocation
7
  try:
8
  import spaces
9
  except ImportError:
10
- HUGGINGFACE_SPACE = False # run on local machine
11
  BATCH_SIZE = 1
12
 
13
  import os
@@ -309,7 +309,7 @@ def _ncut_run(*args, **kwargs):
309
  torch.cuda.empty_cache()
310
  return [], "Error: " + str(e)
311
 
312
- if HUGGINGFACE_SPACE:
313
  @spaces.GPU(duration=20)
314
  def quick_run(*args, **kwargs):
315
  return _ncut_run(*args, **kwargs)
@@ -326,7 +326,7 @@ if HUGGINGFACE_SPACE:
326
  def super_duper_long_run(*args, **kwargs):
327
  return _ncut_run(*args, **kwargs)
328
 
329
- if not HUGGINGFACE_SPACE:
330
  def quick_run(*args, **kwargs):
331
  return _ncut_run(*args, **kwargs)
332
 
@@ -905,7 +905,7 @@ with demo:
905
 
906
 
907
 
908
- if HUGGINGFACE_SPACE:
909
  download_all_models()
910
  download_all_datasets()
911
  demo.launch()
 
1
  # Author: Huzheng Yang
2
  # %%
3
+ USE_HUGGINGFACE_SPACE = True
4
  BATCH_SIZE = 4
5
 
6
+ if USE_HUGGINGFACE_SPACE: # huggingface ZeroGPU, dynamic GPU allocation
7
  try:
8
  import spaces
9
  except ImportError:
10
+ USE_HUGGINGFACE_SPACE = False # run on local machine
11
  BATCH_SIZE = 1
12
 
13
  import os
 
309
  torch.cuda.empty_cache()
310
  return [], "Error: " + str(e)
311
 
312
+ if USE_HUGGINGFACE_SPACE:
313
  @spaces.GPU(duration=20)
314
  def quick_run(*args, **kwargs):
315
  return _ncut_run(*args, **kwargs)
 
326
  def super_duper_long_run(*args, **kwargs):
327
  return _ncut_run(*args, **kwargs)
328
 
329
+ if not USE_HUGGINGFACE_SPACE:
330
  def quick_run(*args, **kwargs):
331
  return _ncut_run(*args, **kwargs)
332
 
 
905
 
906
 
907
 
908
+ if USE_HUGGINGFACE_SPACE:
909
  download_all_models()
910
  download_all_datasets()
911
  demo.launch()
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- torch==2.3.1
2
  torchvision
3
  ncut-pytorch
4
  opencv-python
 
1
+ torch
2
  torchvision
3
  ncut-pytorch
4
  opencv-python