feat: add batch 3D generation script with VRAM optimization

- Add batch_generate.py: two-phase pipeline (shape→texture) that loads
  models sequentially to avoid OOM on RTX 3080
- Fix mesh_utils.py: make bpy import lazy so load_mesh/save_mesh work
  without Blender installed
- Phase 1: shape generation for all images, then unload
- Phase 2: texture generation for all meshes, then unload
- Skip already-generated outputs for resumability
- Tested: 9/9 images successfully generated textured GLB models

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Akasei
2026-03-16 20:20:46 +08:00
parent 82920d643c
commit b6685c9560
4 changed files with 305 additions and 2 deletions

View File

@@ -13,11 +13,18 @@
# by Tencent in accordance with TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT.
from setuptools import setup, find_packages
import os
import torch
from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension
# build custom rasterizer
# CUDA include path: prefer conda env CUDA headers to match torch's CUDA version
_cuda_home = os.environ.get("CUDA_HOME", os.environ.get("CUDA_PATH", "/usr/local/cuda"))
_cuda_include = os.path.join(_cuda_home, "targets", "x86_64-linux", "include")
if not os.path.isdir(_cuda_include):
_cuda_include = os.path.join(_cuda_home, "include")
custom_rasterizer_module = CUDAExtension(
"custom_rasterizer_kernel",
[
@@ -25,6 +32,13 @@ custom_rasterizer_module = CUDAExtension(
"lib/custom_rasterizer_kernel/grid_neighbor.cpp",
"lib/custom_rasterizer_kernel/rasterizer_gpu.cu",
],
include_dirs=[_cuda_include],
# -D__GLIBC_USE_IEC_60559_FUNCS_EXT_C23=0 prevents glibc 2.38+ from declaring
# sinpi/cospi/etc that conflict with CUDA 12.8 crt/math_functions.h on modern glibc.
extra_compile_args={
"nvcc": [],
"cxx": [],
},
)
setup(