cbensimon HF staff commited on
Commit
9cbf97c
·
1 Parent(s): d71f418

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  if 'OMP_NUM_THREADS' not in os.environ:
3
  os.environ['OMP_NUM_THREADS'] = '16'
 
4
  import torch
5
  import subprocess
6
  import gradio as gr
@@ -34,6 +35,9 @@ torch.set_grad_enabled(False)
34
  device = torch.device('cuda')
35
  runner = FreeSplatterRunner(device)
36
 
 
 
 
37
 
38
  _HEADER_ = '''
39
  # FreeSplatter 🤗 Gradio Demo
@@ -82,18 +86,18 @@ with gr.Blocks(analytics_enabled=False, title='FreeSplatter Demo') as demo:
82
  with gr.Tabs() as sub_tabs_img_to_3d:
83
  with gr.TabItem('Hunyuan3D Std', id='tab_hunyuan3d_std'):
84
  _, var_img_to_3d_hunyuan3d_std = create_interface_img_to_3d(
85
- runner.run_segmentation,
86
- runner.run_img_to_3d,
87
  model='Hunyuan3D Std')
88
  with gr.TabItem('Zero123++ v1.1', id='tab_zero123plus_v11'):
89
  _, var_img_to_3d_zero123plus_v11 = create_interface_img_to_3d(
90
- runner.run_segmentation,
91
- runner.run_img_to_3d,
92
  model='Zero123++ v1.1')
93
  with gr.TabItem('Zero123++ v1.2', id='tab_zero123plus_v12'):
94
  _, var_img_to_3d_zero123plus_v12 = create_interface_img_to_3d(
95
- runner.run_segmentation,
96
- runner.run_img_to_3d,
97
  model='Zero123++ v1.2')
98
 
99
  gr.Markdown(_CITE_)
 
1
  import os
2
  if 'OMP_NUM_THREADS' not in os.environ:
3
  os.environ['OMP_NUM_THREADS'] = '16'
4
+ import spaces
5
  import torch
6
  import subprocess
7
  import gradio as gr
 
35
  device = torch.device('cuda')
36
  runner = FreeSplatterRunner(device)
37
 
38
+ run_segmentation = spaces.GPU(partial(runner.run_segmentation, runner))
39
+ run_img_to_3d = spaces.GPU(partial(runner.run_img_to_3d, runner))
40
+
41
 
42
  _HEADER_ = '''
43
  # FreeSplatter 🤗 Gradio Demo
 
86
  with gr.Tabs() as sub_tabs_img_to_3d:
87
  with gr.TabItem('Hunyuan3D Std', id='tab_hunyuan3d_std'):
88
  _, var_img_to_3d_hunyuan3d_std = create_interface_img_to_3d(
89
+ run_segmentation,
90
+ run_img_to_3d,
91
  model='Hunyuan3D Std')
92
  with gr.TabItem('Zero123++ v1.1', id='tab_zero123plus_v11'):
93
  _, var_img_to_3d_zero123plus_v11 = create_interface_img_to_3d(
94
+ run_segmentation,
95
+ run_img_to_3d,
96
  model='Zero123++ v1.1')
97
  with gr.TabItem('Zero123++ v1.2', id='tab_zero123plus_v12'):
98
  _, var_img_to_3d_zero123plus_v12 = create_interface_img_to_3d(
99
+ run_segmentation,
100
+ run_img_to_3d,
101
  model='Zero123++ v1.2')
102
 
103
  gr.Markdown(_CITE_)