feat(gradio): apply VRAM optimization and fix texture config

- generation_all(): offload i23d_worker to CPU before texture gen,
  restore after — mirrors batch_generate.py sequential strategy.
  Prevents OOM when both models peak simultaneously on RTX 3080.
- Change texture config: max_num_view 8→9, resolution 768→512.
  768 resolution OOMs (14.6GB activation); 512 is practical max for
  RTX 3080 20GB. max_views 9 gives better texture coverage.
- Only active when --low_vram_mode flag is passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Akasei
2026-03-16 21:05:14 +08:00
parent e150058012
commit 5d0405dc68

View File

@@ -378,7 +378,19 @@ def generation_all(
tmp_time = time.time()
text_path = os.path.join(save_folder, f'textured_mesh.obj')
# In low_vram_mode: offload shape model to CPU before texture gen to free VRAM,
# mirroring the sequential-load strategy in batch_generate.py.
if args.low_vram_mode:
i23d_worker.to('cpu')
torch.cuda.empty_cache()
path_textured = tex_pipeline(mesh_path=path, image_path=image, output_mesh_path=text_path, save_glb=False)
# Restore shape model to GPU so subsequent requests don't need to reload from disk.
if args.low_vram_mode:
i23d_worker.to('cuda')
torch.cuda.empty_cache()
logger.info("---Texture Generation takes %s seconds ---" % (time.time() - tmp_time))
stats['time']['texture generation'] = time.time() - tmp_time
@@ -796,7 +808,7 @@ if __name__ == '__main__':
# texgen_worker.enable_model_cpu_offload()
from hy3dpaint.textureGenPipeline import Hunyuan3DPaintPipeline, Hunyuan3DPaintConfig
conf = Hunyuan3DPaintConfig(max_num_view=8, resolution=768)
conf = Hunyuan3DPaintConfig(max_num_view=9, resolution=512)
conf.realesrgan_ckpt_path = "hy3dpaint/ckpt/RealESRGAN_x4plus.pth"
conf.multiview_cfg_path = "hy3dpaint/cfgs/hunyuan-paint-pbr.yaml"
conf.custom_pipeline = "hy3dpaint/hunyuanpaintpbr"