Spaces:
Running
on
Zero
Running
on
Zero
add quick_generate_gs
Browse files
app.py
CHANGED
@@ -294,12 +294,33 @@ def quick_generate_glb(
|
|
294 |
)
|
295 |
return extract_glb(state, mesh_simplify=mesh_simplify, texture_size=texture_size, req=req)
|
296 |
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
|
304 |
def test_for_api_gen(image: Image.Image) -> Image.Image:
|
305 |
"""
|
@@ -318,10 +339,26 @@ def test_for_api_gen(image: Image.Image) -> Image.Image:
|
|
318 |
with gr.Blocks(delete_cache=(600, 600)) as demo:
|
319 |
gr.Markdown("""
|
320 |
## Image to 3D Asset with [TRELLIS](https://trellis3d.github.io/)
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
""")
|
326 |
|
327 |
with gr.Row():
|
@@ -360,8 +397,11 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
360 |
extract_glb_btn = gr.Button("Extract GLB", interactive=False)
|
361 |
extract_gs_btn = gr.Button("Extract Gaussian", interactive=False)
|
362 |
generate_glb_btn = gr.Button("Quick Generate GLB in layout")
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
365 |
gr.Markdown("""
|
366 |
*NOTE: Gaussian file can be very large (~50MB), it will take a while to display and download.*
|
367 |
""")
|
@@ -511,14 +551,22 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
511 |
outputs=[model_output, download_glb],
|
512 |
)
|
513 |
|
514 |
-
|
515 |
-
fn=
|
516 |
-
inputs=[
|
517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
)
|
519 |
|
520 |
-
|
521 |
-
|
522 |
|
523 |
|
524 |
# Launch the Gradio app
|
|
|
294 |
)
|
295 |
return extract_glb(state, mesh_simplify=mesh_simplify, texture_size=texture_size, req=req)
|
296 |
|
297 |
+
|
298 |
+
@spaces.GPU(api_name="quick_generate_gs")
|
299 |
+
def quick_generate_gs(
|
300 |
+
image: Image.Image,
|
301 |
+
multiimages: List[Tuple[Image.Image, str]],
|
302 |
+
is_multiimage: bool,
|
303 |
+
seed: int,
|
304 |
+
ss_guidance_strength: float,
|
305 |
+
ss_sampling_steps: int,
|
306 |
+
slat_guidance_strength: float,
|
307 |
+
slat_sampling_steps: int,
|
308 |
+
multiimage_algo: Literal["multidiffusion", "stochastic"],
|
309 |
+
req: gr.Request,
|
310 |
+
) -> Tuple[str, str]:
|
311 |
+
state, _ = image_to_3d(
|
312 |
+
image=image,
|
313 |
+
multiimages=multiimages,
|
314 |
+
is_multiimage=is_multiimage,
|
315 |
+
seed=seed,
|
316 |
+
ss_guidance_strength=ss_guidance_strength,
|
317 |
+
ss_sampling_steps=ss_sampling_steps,
|
318 |
+
slat_guidance_strength=slat_guidance_strength,
|
319 |
+
slat_sampling_steps=slat_sampling_steps,
|
320 |
+
multiimage_algo=multiimage_algo,
|
321 |
+
req=req
|
322 |
+
)
|
323 |
+
return extract_gaussian(state, req=req)
|
324 |
|
325 |
def test_for_api_gen(image: Image.Image) -> Image.Image:
|
326 |
"""
|
|
|
339 |
with gr.Blocks(delete_cache=(600, 600)) as demo:
|
340 |
gr.Markdown("""
|
341 |
## Image to 3D Asset with [TRELLIS](https://trellis3d.github.io/)
|
342 |
+
|
343 |
+
Thanks to the incredible work of [JeffreyXiang/TRELLIS-image-large](https://huggingface.co/JeffreyXiang/TRELLIS-image-large) for providing such a stunning implementation of the TRELLIS 3D pipeline.
|
344 |
+
|
345 |
+
During my usage, I noticed that many users had questions regarding API access. I've spent some time refactoring the `image_to_3d` pipeline and adding two new endpoints:
|
346 |
+
|
347 |
+
- 🔁 `quick_generate_glb`: Directly generate and download a `.glb` 3D asset.
|
348 |
+
- 🌐 `quick_generate_gs`: Directly generate and download the Gaussian `.ply` file.
|
349 |
+
- 🧩 Both functions are exposed as Hugging Face API endpoints and can be called via `gradio_client` or any HTTP client.
|
350 |
+
|
351 |
+
### How to Use:
|
352 |
+
- Upload an image and click **"Generate"** to create a 3D asset. If the image has an alpha channel, it will be used as a mask. Otherwise, `rembg` will automatically remove the background.
|
353 |
+
- If you're satisfied with the result, click **"Extract GLB"** or **"Extract Gaussian"** to download the 3D file.
|
354 |
+
|
355 |
+
### Features:
|
356 |
+
- ✅ Single-image and experimental multi-image generation
|
357 |
+
- ✅ `.glb` extraction with mesh simplification and texturing
|
358 |
+
- ✅ `.ply` (Gaussian) extraction
|
359 |
+
- ✅ Public API endpoints for one-click asset generation and download
|
360 |
+
|
361 |
+
Feel free to try it out and send feedback — I'm happy to keep improving it based on your suggestions!
|
362 |
""")
|
363 |
|
364 |
with gr.Row():
|
|
|
397 |
extract_glb_btn = gr.Button("Extract GLB", interactive=False)
|
398 |
extract_gs_btn = gr.Button("Extract Gaussian", interactive=False)
|
399 |
generate_glb_btn = gr.Button("Quick Generate GLB in layout")
|
400 |
+
|
401 |
+
with gr.Row():
|
402 |
+
quick_generate_glb_btn = gr.Button("Quick Generate GLB")
|
403 |
+
quick_generate_gs_btn = gr.Button("Quick Generate Gaussian")
|
404 |
+
|
405 |
gr.Markdown("""
|
406 |
*NOTE: Gaussian file can be very large (~50MB), it will take a while to display and download.*
|
407 |
""")
|
|
|
551 |
outputs=[model_output, download_glb],
|
552 |
)
|
553 |
|
554 |
+
quick_generate_gs_btn.click(
|
555 |
+
fn=quick_generate_gs,
|
556 |
+
inputs=[
|
557 |
+
image_prompt,
|
558 |
+
multiimage_prompt,
|
559 |
+
is_multiimage,
|
560 |
+
seed,
|
561 |
+
ss_guidance_strength,
|
562 |
+
ss_sampling_steps,
|
563 |
+
slat_guidance_strength,
|
564 |
+
slat_sampling_steps,
|
565 |
+
multiimage_algo,
|
566 |
+
],
|
567 |
+
outputs=[model_output, download_gs],
|
568 |
)
|
569 |
|
|
|
|
|
570 |
|
571 |
|
572 |
# Launch the Gradio app
|