This commit is contained in:
Huiwenshi
2025-06-14 14:32:20 +08:00
parent ed9531ce7e
commit dd93e7ce4e
6 changed files with 29 additions and 18 deletions

23
demo.py
View File

@@ -18,22 +18,25 @@ except Exception as e:
print(f"Warning: Failed to apply torchvision fix: {e}")
# shape
model_path = 'tencent/Hunyuan3D-2.1'
pipeline_shapegen = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(model_path)
#model_path = 'tencent/Hunyuan3D-2.1'
#pipeline_shapegen = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(model_path)
##
#image_path = 'assets/demo.png'
#image = Image.open(image_path).convert("RGBA")
#if image.mode == 'RGB':
# rembg = BackgroundRemover()
# image = rembg(image)
#
image_path = 'assets/demo.png'
image = Image.open(image_path).convert("RGBA")
if image.mode == 'RGB':
rembg = BackgroundRemover()
image = rembg(image)
mesh = pipeline_shapegen(image=image)[0]
mesh.export('demo.glb')
#mesh = pipeline_shapegen(image=image)[0]
#mesh.export('demo.glb')
# paint
max_num_view = 6 # can be 6 to 9
resolution = 512 # can be 768 or 512
conf = Hunyuan3DPaintConfig(max_num_view, resolution)
conf.realesrgan_ckpt_path = "hy3dpaint/ckpt/RealESRGAN_x4plus.pth"
conf.multiview_cfg_path = "hy3dpaint/cfgs/hunyuan-paint-pbr.yaml"
conf.custom_pipeline = "hy3dpaint/hunyuanpaintpbr"
paint_pipeline = Hunyuan3DPaintPipeline(conf)
output_mesh_path = 'demo_textured.glb'