Sm0kyWu commited on
Commit
e90a1d8
·
verified ·
1 Parent(s): a723dd3

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -15
app.py CHANGED
@@ -1,20 +1,8 @@
1
  import gradio as gr
2
  from gradio_litmodel3d import LitModel3D
 
3
 
4
  import os
5
- if os.environ.get("SPACES_ZERO_GPU") is not None:
6
- import spaces
7
- else:
8
- class spaces:
9
- @staticmethod
10
- def GPU(func):
11
- def wrapper(*args, **kwargs):
12
- return func(*args, **kwargs)
13
- return wrapper
14
-
15
- @spaces.GPU
16
- def fake_gpu():
17
- pass
18
 
19
  import shutil
20
  os.environ['SPCONV_ALGO'] = 'native'
@@ -35,7 +23,8 @@ import cv2
35
  MAX_SEED = np.iinfo(np.int32).max
36
  TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
37
  os.makedirs(TMP_DIR, exist_ok=True)
38
-
 
39
 
40
  def start_session(req: gr.Request):
41
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
@@ -555,4 +544,5 @@ if __name__ == "__main__":
555
  pipeline.preprocess_image(Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8)))
556
  except:
557
  pass
558
- demo.launch()
 
 
1
  import gradio as gr
2
  from gradio_litmodel3d import LitModel3D
3
+ import spaces
4
 
5
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  import shutil
8
  os.environ['SPCONV_ALGO'] = 'native'
 
23
  MAX_SEED = np.iinfo(np.int32).max
24
  TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
25
  os.makedirs(TMP_DIR, exist_ok=True)
26
+ torch.set_grad_enabled(False)
27
+ device = torch.device('cuda')
28
 
29
  def start_session(req: gr.Request):
30
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
 
544
  pipeline.preprocess_image(Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8)))
545
  except:
546
  pass
547
+ demo.queue(max_size=1)
548
+ demo.launch(share=False)