Spaces:
Running
on
Zero
Running
on
Zero
Upload folder using huggingface_hub
Browse files- app.py +14 -6
- src/infer_gsdiff_pas.py +2 -2
app.py
CHANGED
|
@@ -10,6 +10,16 @@ import sys
|
|
| 10 |
from loguru import logger
|
| 11 |
current_path = os.path.dirname(os.path.abspath(__file__))
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
MAX_SEED = np.iinfo(np.int32).max
|
| 14 |
TMP_DIR = os.path.join(current_path, 'out')
|
| 15 |
os.makedirs(TMP_DIR, exist_ok=True)
|
|
@@ -50,6 +60,7 @@ txt_commands = "PYTHONPATH=./ bash scripts/infer.sh src/infer_gsdiff_pas.py con
|
|
| 50 |
# process function
|
| 51 |
@spaces.GPU
|
| 52 |
def process(input_image, prompt='a_high_quality_3D_asset', prompt_neg='poor_quality', input_elevation=20, guidance_scale=2., input_seed=0):
|
|
|
|
| 53 |
# subprocess.run("cd extensions/RaDe-GS/submodules && pip3 install diff-gaussian-rasterization", shell=True)
|
| 54 |
# subprocess.run("cd extensions/RaDe-GS/submodules/diff-gaussian-rasterization && python3 setup.py bdist_wheel ", shell=True)
|
| 55 |
|
|
@@ -124,8 +135,7 @@ with block:
|
|
| 124 |
|
| 125 |
# elevation
|
| 126 |
input_elevation = gr.Slider(label="elevation", minimum=-90, maximum=90, step=1, value=10)
|
| 127 |
-
|
| 128 |
-
# input_num_steps = gr.Slider(label="inference steps", minimum=1, maximum=100, step=1, value=30)
|
| 129 |
# random seed
|
| 130 |
input_seed = gr.Slider(label="random seed", minimum=0, maximum=100000, step=1, value=0)
|
| 131 |
# gen button
|
|
@@ -151,8 +161,7 @@ with block:
|
|
| 151 |
],
|
| 152 |
inputs=[input_image],
|
| 153 |
outputs=[output_image, output_video, output_file],
|
| 154 |
-
fn=lambda x: process(input_image=x),
|
| 155 |
-
# cache_examples=True,
|
| 156 |
run_on_click=True,
|
| 157 |
label='Image-to-3D Examples'
|
| 158 |
)
|
|
@@ -166,8 +175,7 @@ with block:
|
|
| 166 |
inputs=[input_text],
|
| 167 |
outputs=[output_image, output_video, output_file],
|
| 168 |
fn=lambda x: process(input_image=None, prompt=x),
|
| 169 |
-
|
| 170 |
-
# run_on_click=True,
|
| 171 |
label='Text-to-3D Examples'
|
| 172 |
)
|
| 173 |
|
|
|
|
| 10 |
from loguru import logger
|
| 11 |
current_path = os.path.dirname(os.path.abspath(__file__))
|
| 12 |
|
| 13 |
+
# try:
|
| 14 |
+
# import diff_gaussian_rasterization # noqa: F401
|
| 15 |
+
# except ImportError:
|
| 16 |
+
# @spaces.GPU
|
| 17 |
+
# def install_diff_gaussian_rasterization():
|
| 18 |
+
# os.system("pip install ./extensions/RaDe-GS/submodules/diff-gaussian-rasterization")
|
| 19 |
+
# install_diff_gaussian_rasterization()
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
MAX_SEED = np.iinfo(np.int32).max
|
| 24 |
TMP_DIR = os.path.join(current_path, 'out')
|
| 25 |
os.makedirs(TMP_DIR, exist_ok=True)
|
|
|
|
| 60 |
# process function
|
| 61 |
@spaces.GPU
|
| 62 |
def process(input_image, prompt='a_high_quality_3D_asset', prompt_neg='poor_quality', input_elevation=20, guidance_scale=2., input_seed=0):
|
| 63 |
+
# fail to install RaDe-GS
|
| 64 |
# subprocess.run("cd extensions/RaDe-GS/submodules && pip3 install diff-gaussian-rasterization", shell=True)
|
| 65 |
# subprocess.run("cd extensions/RaDe-GS/submodules/diff-gaussian-rasterization && python3 setup.py bdist_wheel ", shell=True)
|
| 66 |
|
|
|
|
| 135 |
|
| 136 |
# elevation
|
| 137 |
input_elevation = gr.Slider(label="elevation", minimum=-90, maximum=90, step=1, value=10)
|
| 138 |
+
|
|
|
|
| 139 |
# random seed
|
| 140 |
input_seed = gr.Slider(label="random seed", minimum=0, maximum=100000, step=1, value=0)
|
| 141 |
# gen button
|
|
|
|
| 161 |
],
|
| 162 |
inputs=[input_image],
|
| 163 |
outputs=[output_image, output_video, output_file],
|
| 164 |
+
fn=lambda x: process(input_image=x,input_elevation=input_elevation,),
|
|
|
|
| 165 |
run_on_click=True,
|
| 166 |
label='Image-to-3D Examples'
|
| 167 |
)
|
|
|
|
| 175 |
inputs=[input_text],
|
| 176 |
outputs=[output_image, output_video, output_file],
|
| 177 |
fn=lambda x: process(input_image=None, prompt=x),
|
| 178 |
+
run_on_click=True,
|
|
|
|
| 179 |
label='Text-to-3D Examples'
|
| 180 |
)
|
| 181 |
|
src/infer_gsdiff_pas.py
CHANGED
|
@@ -610,9 +610,9 @@ def main():
|
|
| 610 |
save_gif = "gif" in args.output_video_type
|
| 611 |
|
| 612 |
if fancy_video:
|
| 613 |
-
render_azimuths = np.arange(0., 720.,
|
| 614 |
else:
|
| 615 |
-
render_azimuths = np.arange(0., 360.,
|
| 616 |
|
| 617 |
C2W = []
|
| 618 |
for i in range(len(render_azimuths)):
|
|
|
|
| 610 |
save_gif = "gif" in args.output_video_type
|
| 611 |
|
| 612 |
if fancy_video:
|
| 613 |
+
render_azimuths = np.arange(0., 720., 40)
|
| 614 |
else:
|
| 615 |
+
render_azimuths = np.arange(0., 360., 10)
|
| 616 |
|
| 617 |
C2W = []
|
| 618 |
for i in range(len(render_azimuths)):
|