Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -214,7 +214,37 @@ def run_triposg(image_path: str,
|
|
| 214 |
progress=gr.Progress(track_tqdm=True),):
|
| 215 |
|
| 216 |
"""
|
| 217 |
-
Generate 3D
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
"""
|
| 219 |
|
| 220 |
max_num_expanded_coords = 1e9
|
|
@@ -384,4 +414,4 @@ if __name__ == "__main__":
|
|
| 384 |
demo = build_demo()
|
| 385 |
demo.unload(cleanup)
|
| 386 |
demo.queue()
|
| 387 |
-
demo.launch()
|
|
|
|
| 214 |
progress=gr.Progress(track_tqdm=True),):
|
| 215 |
|
| 216 |
"""
|
| 217 |
+
Generate structured 3D meshes from a 2D image using the PartCrafter pipeline.
|
| 218 |
+
|
| 219 |
+
This function takes a single 2D image as input and produces a set of part-based 3D meshes,
|
| 220 |
+
using compositional latent diffusion with attention to structure and part separation.
|
| 221 |
+
Optionally removes the background using a pretrained background removal model (RMBG),
|
| 222 |
+
and outputs a merged object mesh, a split preview (exploded view), and a downloadable ZIP of all parts.
|
| 223 |
+
|
| 224 |
+
Args:
|
| 225 |
+
image_path (str): Path to the input image file on disk.
|
| 226 |
+
num_parts (int, optional): Number of distinct parts to decompose the object into. Defaults to 1.
|
| 227 |
+
seed (int, optional): Random seed for reproducibility. Defaults to 0.
|
| 228 |
+
num_tokens (int, optional): Number of tokens used during latent encoding. Higher values yield finer detail. Defaults to 1024.
|
| 229 |
+
num_inference_steps (int, optional): Number of diffusion inference steps. More steps improve quality but increase runtime. Defaults to 50.
|
| 230 |
+
guidance_scale (float, optional): Classifier-free guidance scale. Higher values emphasize adherence to conditioning. Defaults to 7.0.
|
| 231 |
+
use_flash_decoder (bool, optional): Whether to use FlashAttention in the decoder for performance. Defaults to False.
|
| 232 |
+
rmbg (bool, optional): Whether to apply background removal before processing. Defaults to True.
|
| 233 |
+
session_id (str, optional): Optional session ID to manage export paths. If not provided, a random UUID is generated.
|
| 234 |
+
progress (gr.Progress, optional): Gradio progress object for visual feedback. Automatically handled by Gradio.
|
| 235 |
+
|
| 236 |
+
Returns:
|
| 237 |
+
Tuple[str, str, str, str]:
|
| 238 |
+
- `merged_path` (str): File path to the merged full object mesh (`object.glb`).
|
| 239 |
+
- `split_preview_path` (str): File path to the exploded-view mesh (`split.glb`).
|
| 240 |
+
- `export_dir` (str): Directory where all generated meshes were saved.
|
| 241 |
+
- `zip_path` (str): Path to the ZIP file containing all individual part meshes.
|
| 242 |
+
|
| 243 |
+
Notes:
|
| 244 |
+
- This function utilizes HuggingFace pretrained weights for both part generation and background removal.
|
| 245 |
+
- The final output includes exploded and merged views to visualize object structure.
|
| 246 |
+
- Parts are exported in `.glb` format, and zipped for bulk download.
|
| 247 |
+
- Generation time depends on the number of parts and inference parameters.
|
| 248 |
"""
|
| 249 |
|
| 250 |
max_num_expanded_coords = 1e9
|
|
|
|
| 414 |
demo = build_demo()
|
| 415 |
demo.unload(cleanup)
|
| 416 |
demo.queue()
|
| 417 |
+
demo.launch(mcp_server=True)
|