Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,23 @@ import shutil
|
|
7 |
import subprocess
|
8 |
import sys
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
os.environ['SPCONV_ALGO'] = 'native'
|
11 |
from typing import *
|
12 |
import torch
|
@@ -257,11 +274,11 @@ def split_image(image: Image.Image) -> List[Image.Image]:
|
|
257 |
|
258 |
with gr.Blocks(delete_cache=(600, 600)) as demo:
|
259 |
gr.Markdown("""
|
260 |
-
##
|
261 |
* Upload an image and click "Generate" to create a 3D asset. If the image has alpha channel, it be used as the mask. Otherwise, we use `rembg` to remove the background.
|
262 |
* If you find the generated 3D asset satisfactory, click "Extract GLB" to extract the GLB file and download it.
|
263 |
|
264 |
-
✨
|
265 |
""")
|
266 |
|
267 |
with gr.Row():
|
@@ -342,11 +359,11 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
342 |
demo.unload(end_session)
|
343 |
|
344 |
single_image_input_tab.select(
|
345 |
-
lambda: tuple([False, gr.
|
346 |
outputs=[is_multiimage, single_image_example, multiimage_example]
|
347 |
)
|
348 |
multiimage_input_tab.select(
|
349 |
-
lambda: tuple([True, gr.
|
350 |
outputs=[is_multiimage, single_image_example, multiimage_example]
|
351 |
)
|
352 |
|
@@ -370,12 +387,12 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
370 |
inputs=[image_prompt, multiimage_prompt, is_multiimage, seed, ss_guidance_strength, ss_sampling_steps, slat_guidance_strength, slat_sampling_steps, multiimage_algo],
|
371 |
outputs=[output_buf, video_output],
|
372 |
).then(
|
373 |
-
lambda: tuple([gr.
|
374 |
outputs=[extract_glb_btn, extract_gs_btn],
|
375 |
)
|
376 |
|
377 |
video_output.clear(
|
378 |
-
lambda: tuple([gr.
|
379 |
outputs=[extract_glb_btn, extract_gs_btn],
|
380 |
)
|
381 |
|
@@ -384,7 +401,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
384 |
inputs=[output_buf, mesh_simplify, texture_size],
|
385 |
outputs=[model_output, download_glb],
|
386 |
).then(
|
387 |
-
lambda: gr.
|
388 |
outputs=[download_glb],
|
389 |
)
|
390 |
|
@@ -393,12 +410,12 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
393 |
inputs=[output_buf],
|
394 |
outputs=[model_output, download_gs],
|
395 |
).then(
|
396 |
-
lambda: gr.
|
397 |
outputs=[download_gs],
|
398 |
)
|
399 |
|
400 |
model_output.clear(
|
401 |
-
lambda: gr.
|
402 |
outputs=[download_glb],
|
403 |
)
|
404 |
|
|
|
7 |
import subprocess
|
8 |
import sys
|
9 |
|
10 |
+
# Install local wheels at runtime
|
11 |
+
def install_local_wheels():
|
12 |
+
"""Install the local wheel files that couldn't be installed during Docker build."""
|
13 |
+
wheels_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wheels')
|
14 |
+
if os.path.exists(wheels_dir):
|
15 |
+
wheel_files = [f for f in os.listdir(wheels_dir) if f.endswith('.whl')]
|
16 |
+
for wheel_file in wheel_files:
|
17 |
+
wheel_path = os.path.join(wheels_dir, wheel_file)
|
18 |
+
try:
|
19 |
+
subprocess.check_call([sys.executable, '-m', 'pip', 'install', wheel_path])
|
20 |
+
print(f"Successfully installed {wheel_file}")
|
21 |
+
except subprocess.CalledProcessError as e:
|
22 |
+
print(f"Failed to install {wheel_file}: {e}")
|
23 |
+
|
24 |
+
# Install wheels before importing trellis
|
25 |
+
install_local_wheels()
|
26 |
+
|
27 |
os.environ['SPCONV_ALGO'] = 'native'
|
28 |
from typing import *
|
29 |
import torch
|
|
|
274 |
|
275 |
with gr.Blocks(delete_cache=(600, 600)) as demo:
|
276 |
gr.Markdown("""
|
277 |
+
## ASM - Advanced Spatial Modeling for 3D Generation
|
278 |
* Upload an image and click "Generate" to create a 3D asset. If the image has alpha channel, it be used as the mask. Otherwise, we use `rembg` to remove the background.
|
279 |
* If you find the generated 3D asset satisfactory, click "Extract GLB" to extract the GLB file and download it.
|
280 |
|
281 |
+
✨Features: 1) Multi-image support. 2) Gaussian file extraction. 3) Advanced 3D generation.
|
282 |
""")
|
283 |
|
284 |
with gr.Row():
|
|
|
359 |
demo.unload(end_session)
|
360 |
|
361 |
single_image_input_tab.select(
|
362 |
+
lambda: tuple([False, gr.update(visible=True), gr.update(visible=False)]),
|
363 |
outputs=[is_multiimage, single_image_example, multiimage_example]
|
364 |
)
|
365 |
multiimage_input_tab.select(
|
366 |
+
lambda: tuple([True, gr.update(visible=False), gr.update(visible=True)]),
|
367 |
outputs=[is_multiimage, single_image_example, multiimage_example]
|
368 |
)
|
369 |
|
|
|
387 |
inputs=[image_prompt, multiimage_prompt, is_multiimage, seed, ss_guidance_strength, ss_sampling_steps, slat_guidance_strength, slat_sampling_steps, multiimage_algo],
|
388 |
outputs=[output_buf, video_output],
|
389 |
).then(
|
390 |
+
lambda: tuple([gr.update(interactive=True), gr.update(interactive=True)]),
|
391 |
outputs=[extract_glb_btn, extract_gs_btn],
|
392 |
)
|
393 |
|
394 |
video_output.clear(
|
395 |
+
lambda: tuple([gr.update(interactive=False), gr.update(interactive=False)]),
|
396 |
outputs=[extract_glb_btn, extract_gs_btn],
|
397 |
)
|
398 |
|
|
|
401 |
inputs=[output_buf, mesh_simplify, texture_size],
|
402 |
outputs=[model_output, download_glb],
|
403 |
).then(
|
404 |
+
lambda: gr.update(interactive=True),
|
405 |
outputs=[download_glb],
|
406 |
)
|
407 |
|
|
|
410 |
inputs=[output_buf],
|
411 |
outputs=[model_output, download_gs],
|
412 |
).then(
|
413 |
+
lambda: gr.update(interactive=True),
|
414 |
outputs=[download_gs],
|
415 |
)
|
416 |
|
417 |
model_output.clear(
|
418 |
+
lambda: gr.update(interactive=False),
|
419 |
outputs=[download_glb],
|
420 |
)
|
421 |
|