Skip to content

Hy3d platform#1261

Open
Watebear wants to merge 4 commits into
mainfrom
hy3d_platform
Open

Hy3d platform#1261
Watebear wants to merge 4 commits into
mainfrom
hy3d_platform

Conversation

@Watebear

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Hunyuan3D on the Ascend NPU platform, including configuration files, an end-to-end execution script, and support for custom render and texture sizes in the paint pipeline. It also defers the initialization of the optional rembg dependency and captures import errors for skimage. Feedback on these changes highlights that the new shell script contains non-portable hardcoded paths and suggests refactoring it to use environment variables. Additionally, the captured _measure_import_error is currently unused and should be raised when skimage is missing to provide a clearer error message.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +5 to +64
lightx2v_path=${LIGHTX2V_PATH:-/data/wushuo1/LightX2V}
hy_repo=${HUNYUAN3D_REPO:-/data/wushuo1/Hunyuan3D-2.1-platform}
model_path=${HUNYUAN3D_MODEL_PATH:-/data/wushuo1/models/Hunyuan3D-2.1}
python_bin=${HUNYUAN3D_PYTHON:-/data/wushuo1/envs/hunyuan3d-ascend/bin/python}

if [[ ! -s "${hy_repo}/hy3dpaint/ckpt/RealESRGAN_x4plus.pth" ]]; then
echo "Missing RealESRGAN checkpoint: ${hy_repo}/hy3dpaint/ckpt/RealESRGAN_x4plus.pth" >&2
echo "Download it as documented in ${hy_repo}/README.md." >&2
exit 1
fi

export PLATFORM=ascend_npu
export ASCEND_RT_VISIBLE_DEVICES=0
export AI_DEVICE=npu
export HF_MODULES_CACHE=/data/wushuo1/cache/huggingface/hunyuan3d_ascend_modules
export PYTHONPATH=${PYTHONPATH:-}

source "${lightx2v_path}/scripts/base/base.sh"
export DTYPE=FP16
export PROFILING_DEBUG_LEVEL=1

mkdir -p \
"${lightx2v_path}/save_results/hunyuan3d" \
/data/wushuo1/cache/hunyuan3d/shape \
"${HF_MODULES_CACHE}"

echo "=== Step 1/2: shape generation ==="
cd /data/wushuo1/cache/hunyuan3d/shape
"${python_bin}" -m lightx2v.infer \
--model_cls hunyuan3d \
--task i23d \
--model_path "${model_path}" \
--config_json "${lightx2v_path}/configs/platforms/ascend_npu/hunyuan3d_shape.json" \
--image_path "${hy_repo}/assets/demo.png" \
--save_result_path "${lightx2v_path}/save_results/hunyuan3d/e2e_shape.glb" \
--seed 42

test -s "${lightx2v_path}/save_results/hunyuan3d/e2e_shape.glb"
echo "Saved mesh: ${lightx2v_path}/save_results/hunyuan3d/e2e_shape.glb"

extra_args=()
if [[ "${HUNYUAN3D_NO_REMESH:-0}" == "1" ]]; then
extra_args+=(--no_remesh)
fi

echo "=== Step 2/2: mesh texture (paint) ==="
"${python_bin}" "${lightx2v_path}/tools/postprocess/postprocess_paint.py" \
--hy_repo "${hy_repo}" \
--model_path "${model_path}" \
--mesh_path "${lightx2v_path}/save_results/hunyuan3d/e2e_shape.glb" \
--image_path "${hy_repo}/assets/demo.png" \
--save_path "${lightx2v_path}/save_results/hunyuan3d/e2e_textured.glb" \
--device npu \
--dino_ckpt_path /data/wushuo1/models/dinov2-giant \
--realesrgan_ckpt_path "${hy_repo}/hy3dpaint/ckpt/RealESRGAN_x4plus.pth" \
--render_size 2048 \
--texture_size 4096 \
--max_num_view 6 \
--resolution 512 \
"${extra_args[@]}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The script contains several hardcoded paths specific to a single user's environment (e.g., /data/wushuo1/...). This makes the script non-portable and will cause it to fail immediately for other users or on different environments.

Consider refactoring the script to use standard cache directories (like ~/.cache) and require the user to set environment variables for external paths (like HUNYUAN3D_REPO and HUNYUAN3D_MODEL_PATH), exiting with a helpful error message if they are missing.

lightx2v_path=${LIGHTX2V_PATH:-$(pwd)}
hy_repo=${HUNYUAN3D_REPO:-}
model_path=${HUNYUAN3D_MODEL_PATH:-}
python_bin=${HUNYUAN3D_PYTHON:-python}

if [[ -z "${hy_repo}" || -z "${model_path}" ]]; then
    echo "Error: HUNYUAN3D_REPO and HUNYUAN3D_MODEL_PATH environment variables must be set." >&2
    exit 1
fi

if [[ ! -s "${hy_repo}/hy3dpaint/ckpt/RealESRGAN_x4plus.pth" ]]; then
    echo "Missing RealESRGAN checkpoint: ${hy_repo}/hy3dpaint/ckpt/RealESRGAN_x4plus.pth" >&2
    echo "Download it as documented in ${hy_repo}/README.md." >&2
    exit 1
fi

export PLATFORM=ascend_npu
export ASCEND_RT_VISIBLE_DEVICES=0
export AI_DEVICE=npu
export HF_MODULES_CACHE=${HF_MODULES_CACHE:-~/.cache/huggingface/hunyuan3d_ascend_modules}
export PYTHONPATH=${PYTHONPATH:-}

source "${lightx2v_path}/scripts/base/base.sh"
export DTYPE=FP16
export PROFILING_DEBUG_LEVEL=1

shape_cache_dir=${HUNYUAN3D_CACHE_SHAPE:-~/.cache/hunyuan3d/shape}

mkdir -p "${lightx2v_path}/save_results/hunyuan3d" "${shape_cache_dir}" "${HF_MODULES_CACHE}"

echo "=== Step 1/2: shape generation ==="
cd "${shape_cache_dir}"
"${python_bin}" -m lightx2v.infer --model_cls hunyuan3d --task i23d --model_path "${model_path}" --config_json "${lightx2v_path}/configs/platforms/ascend_npu/hunyuan3d_shape.json" --image_path "${hy_repo}/assets/demo.png" --save_result_path "${lightx2v_path}/save_results/hunyuan3d/e2e_shape.glb" --seed 42

test -s "${lightx2v_path}/save_results/hunyuan3d/e2e_shape.glb"
echo "Saved mesh: ${lightx2v_path}/save_results/hunyuan3d/e2e_shape.glb"

extra_args=()
if [[ "${HUNYUAN3D_NO_REMESH:-0}" == "1" ]]; then
    extra_args+=(--no_remesh)
fi

echo "=== Step 2/2: mesh texture (paint) ==="
"${python_bin}" "${lightx2v_path}/tools/postprocess/postprocess_paint.py" --hy_repo "${hy_repo}" --model_path "${model_path}" --mesh_path "${lightx2v_path}/save_results/hunyuan3d/e2e_shape.glb" --image_path "${hy_repo}/assets/demo.png" --save_path "${lightx2v_path}/save_results/hunyuan3d/e2e_textured.glb" --device npu --dino_ckpt_path "${HUNYUAN3D_DINO_CKPT:-facebook/dinov2-giant}" --realesrgan_ckpt_path "${hy_repo}/hy3dpaint/ckpt/RealESRGAN_x4plus.pth" --render_size 2048 --texture_size 4096 --max_num_view 6 --resolution 512 "${extra_args[@]}"

Comment on lines +22 to +26
except ImportError as exc:
measure = None
_measure_import_error = exc
else:
_measure_import_error = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable _measure_import_error is defined when skimage import fails, but it is never used. If skimage is not installed, calling MCSurfaceExtractor.run will fail with an unhelpful AttributeError: 'NoneType' object has no attribute 'marching_cubes'.

Consider checking if measure is None and raising _measure_import_error (or a clear ImportError) inside MCSurfaceExtractor.run to provide a more helpful error message, similar to how DMCSurfaceExtractor handles its missing dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant