mirror of
https://git.datalinker.icu/kijai/ComfyUI-Hunyuan3DWrapper.git
synced 2025-12-08 20:34:28 +08:00
when custom_rasterizer_kernel is imported before torch under cu128/python 3.12, the following error will raise: ImportError: DLL load failed while importing custom_rasterizer_kernel: 找不到指定的模块。 simply swapping these two imports will solve this issue
42 lines
2.1 KiB
Python
Executable File
42 lines
2.1 KiB
Python
Executable File
# Open Source Model Licensed under the Apache License Version 2.0
|
|
# and Other Licenses of the Third-Party Components therein:
|
|
# The below Model in this distribution may have been modified by THL A29 Limited
|
|
# ("Tencent Modifications"). All Tencent Modifications are Copyright (C) 2024 THL A29 Limited.
|
|
|
|
# Copyright (C) 2024 THL A29 Limited, a Tencent company. All rights reserved.
|
|
# The below software and/or models in this distribution may have been
|
|
# modified by THL A29 Limited ("Tencent Modifications").
|
|
# All Tencent Modifications are Copyright (C) THL A29 Limited.
|
|
|
|
# Hunyuan 3D is licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT
|
|
# except for the third-party components listed below.
|
|
# Hunyuan 3D does not impose any additional limitations beyond what is outlined
|
|
# in the repsective licenses of these third-party components.
|
|
# Users must comply with all terms and conditions of original licenses of these third-party
|
|
# components and must ensure that the usage of the third party components adheres to
|
|
# all relevant laws and regulations.
|
|
|
|
# For avoidance of doubts, Hunyuan 3D means the large language models and
|
|
# their software and algorithms, including trained model weights, parameters (including
|
|
# optimizer states), machine-learning model code, inference-enabling code, training-enabling code,
|
|
# fine-tuning enabling code and other elements of the foregoing made publicly available
|
|
# by Tencent in accordance with TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT.
|
|
|
|
import torch
|
|
import custom_rasterizer_kernel
|
|
|
|
|
|
def rasterize(pos, tri, resolution, clamp_depth=torch.zeros(0), use_depth_prior=0):
|
|
assert (pos.device == tri.device)
|
|
findices, barycentric = custom_rasterizer_kernel.rasterize_image(pos[0], tri, clamp_depth, resolution[1],
|
|
resolution[0], 1e-6, use_depth_prior)
|
|
return findices, barycentric
|
|
|
|
|
|
def interpolate(col, findices, barycentric, tri):
|
|
f = findices - 1 + (findices == 0)
|
|
vcol = col[0, tri.long()[f.long()]]
|
|
result = barycentric.view(*barycentric.shape, 1) * vcol
|
|
result = torch.sum(result, axis=-2)
|
|
return result.view(1, *result.shape)
|