diff --git a/gradio_app.py b/gradio_app.py index 46b219d..b300a61 100644 --- a/gradio_app.py +++ b/gradio_app.py @@ -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"