cbensimon HF staff commited on
Commit
9ae28d8
1 Parent(s): 3f48d77

Working ZeroGPU version

Browse files
Files changed (1) hide show
  1. app.py +11 -26
app.py CHANGED
@@ -1,6 +1,8 @@
 
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
@@ -11,30 +13,16 @@ from freesplatter.webui.runner import FreeSplatterRunner
11
  from freesplatter.webui.tab_img_to_3d import create_interface_img_to_3d
12
 
13
 
14
- def install_cuda_toolkit():
15
- CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.30.02_linux.run"
16
- CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
17
- subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
18
- subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
19
- subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
20
-
21
- os.environ["CUDA_HOME"] = "/usr/local/cuda"
22
- os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
23
- os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
24
- os.environ["CUDA_HOME"],
25
- "" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
26
- )
27
- # Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
28
- os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
29
-
30
- install_cuda_toolkit()
31
-
32
-
33
  torch.set_grad_enabled(False)
34
  device = torch.device('cuda')
35
  runner = FreeSplatterRunner(device)
36
 
37
 
 
 
 
 
 
38
  _HEADER_ = '''
39
  # FreeSplatter 🤗 Gradio Demo
40
  \n\nOfficial demo of the paper [FreeSplatter: Pose-free Gaussian Splatting for Sparse-view 3D Reconstruction](https://arxiv.org/abs/2404.07191). [[Github]](https://github.com/TencentARC/FreeSplatter)
@@ -82,20 +70,17 @@ 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_)
100
 
101
- demo.launch()
 
1
+ import open3d_zerogpu_fix
2
  import os
3
  if 'OMP_NUM_THREADS' not in os.environ:
4
  os.environ['OMP_NUM_THREADS'] = '16'
5
+ import spaces
6
  import torch
7
  import subprocess
8
  import gradio as gr
 
13
  from freesplatter.webui.tab_img_to_3d import create_interface_img_to_3d
14
 
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  torch.set_grad_enabled(False)
17
  device = torch.device('cuda')
18
  runner = FreeSplatterRunner(device)
19
 
20
 
21
+ @spaces.GPU(duration=120)
22
+ def run_img_to_3d(*args):
23
+ yield from runner.run_img_to_3d(*args, cache_dir=gr.utils.get_upload_folder())
24
+
25
+
26
  _HEADER_ = '''
27
  # FreeSplatter 🤗 Gradio Demo
28
  \n\nOfficial demo of the paper [FreeSplatter: Pose-free Gaussian Splatting for Sparse-view 3D Reconstruction](https://arxiv.org/abs/2404.07191). [[Github]](https://github.com/TencentARC/FreeSplatter)
 
70
  with gr.Tabs() as sub_tabs_img_to_3d:
71
  with gr.TabItem('Hunyuan3D Std', id='tab_hunyuan3d_std'):
72
  _, var_img_to_3d_hunyuan3d_std = create_interface_img_to_3d(
73
+ run_img_to_3d,
 
74
  model='Hunyuan3D Std')
75
  with gr.TabItem('Zero123++ v1.1', id='tab_zero123plus_v11'):
76
  _, var_img_to_3d_zero123plus_v11 = create_interface_img_to_3d(
77
+ run_img_to_3d,
 
78
  model='Zero123++ v1.1')
79
  with gr.TabItem('Zero123++ v1.2', id='tab_zero123plus_v12'):
80
  _, var_img_to_3d_zero123plus_v12 = create_interface_img_to_3d(
81
+ run_img_to_3d,
 
82
  model='Zero123++ v1.2')
83
 
84
  gr.Markdown(_CITE_)
85
 
86
+ demo.launch()