update v2.5; update 3d viewer

This commit is contained in:
liangd
2025-01-24 12:44:04 +08:00
parent e63f927b6f
commit 1eef2a3f41
8 changed files with 29 additions and 42 deletions
+22 -18
View File
@@ -25,7 +25,7 @@ class TripoGLBViewer:
def INPUT_TYPES(s):
return {
"required": {
"mesh": ("MESH",)
"mesh": ("STRING",)
}
}
@@ -57,9 +57,9 @@ class TripoAPIDraft:
"image_left": ("IMAGE",),
"image_back": ("IMAGE",),
"image_right": ("IMAGE",),
"multiview_orth_proj": ("BOOLEAN", {"default": False}),
"model_version": (["v1.4-20240625", "v2.0-20240919"], {"default": "v2.0-20240919"}),
"style": (["person:person2cartoon", "animal:venom", "object:clay", "object:steampunk", "None"], {"default": "None"}),
"model_version": (["v1.4-20240625", "v2.0-20240919", "v2.5-20250123"], {"default": "v2.5-20250123"}),
"style": (["person:person2cartoon", "animal:venom", "object:clay", "object:steampunk",
"object:barbie", "object:christmas", "gold", "ancient_bronze", "None"], {"default": "None"}),
"texture": ("BOOLEAN", {"default": True}),
"pbr": ("BOOLEAN", {"default": True}),
"image_seed": ("INT", {"default": 42}),
@@ -68,32 +68,35 @@ class TripoAPIDraft:
"texture_quality": (["standard", "detailed"], {"default": "standard"}),
"texture_alignment": (["original_image", "geometry"], {"default": "original_image"}),
"face_limit": ("INT", {"min": -1, "max": 500000, "default": -1}),
"quad": ("BOOLEAN", {"default": False}),
}
}
config["required"]["apikey"] = ("STRING", {"default": ""})
return config
if not tripo_api_key:
RETURN_TYPES = ("MESH", "MODEL_TASK_ID", "API_KEY",)
RETURN_TYPES = ("STRING", "MODEL_TASK_ID", "API_KEY",)
RETURN_NAMES = ("model_file", "model task_id", "API KEY")
else:
RETURN_TYPES = ("MESH", "MODEL_TASK_ID",)
RETURN_TYPES = ("STRING", "MODEL_TASK_ID",)
RETURN_NAMES = ("model_file", "model task_id")
FUNCTION = "generate_mesh"
CATEGORY = "TripoAPI"
def generate_mesh(self, mode, prompt=None, image=None, image_left=None, image_back=None, image_right=None,
multiview_orth_proj=None, apikey=None, model_version=None, texture=None, pbr=None, style=None,
image_seed=None, model_seed=None, texture_seed=None, texture_quality=None, texture_alignment=None, face_limit=None):
image_seed=None, model_seed=None, texture_seed=None, texture_quality=None, texture_alignment=None, face_limit=None, quad=None):
api, key = GetTripoAPI(apikey)
if mode == "text_to_model":
if not prompt:
raise RuntimeError("Prompt is required")
result = api.text_to_3d(prompt, model_version, texture, pbr, image_seed, model_seed, texture_seed, texture_quality, face_limit)
result = api.text_to_3d(prompt, model_version, style, texture, pbr, image_seed, model_seed, texture_seed, texture_quality, face_limit, quad)
elif mode == 'image_to_model':
if image is None:
raise RuntimeError("Image is required")
image_name = save_tensor(image, os.path.join(get_input_directory(), "image"))
result = api.image_to_3d(image_name, model_version, style, texture, pbr, model_seed, texture_seed, texture_quality, texture_alignment, face_limit)
result = api.image_to_3d(image_name, model_version, style, texture, pbr, model_seed, texture_seed, texture_quality, texture_alignment, face_limit, quad)
elif mode == 'multiview_to_model':
if image is None:
raise RuntimeError("front image for multiview is required")
@@ -104,12 +107,9 @@ class TripoAPIDraft:
any_image = i
break
if any_image is None:
raise RuntimeError("any other images for multiview are required for v2.0")
raise RuntimeError("any other images for multiview are required for >=v2.0")
else:
if (image_left is None) ^ (image_right is None):
raise RuntimeError("only one of left or right image is required for multiview v1.4")
if image_back is None:
raise RuntimeError("back image for multiview 1.4 is required")
raise RuntimeError("multiview v1.4 is not supported")
image_names = []
for image_name in ["image", "image_left", "image_back", "image_right"]:
image_ = locals()[image_name]
@@ -143,7 +143,8 @@ class TripoTextureModel:
config["required"]["apikey"] = ("API_KEY",)
return config
RETURN_TYPES = ("MESH", "MODEL_TASK_ID",)
RETURN_TYPES = ("STRING", "MODEL_TASK_ID",)
RETURN_NAMES = ("model_file", "model task_id")
FUNCTION = "generate_mesh"
CATEGORY = "TripoAPI"
@@ -168,7 +169,8 @@ class TripoRefineModel:
config["required"]["apikey"] = ("API_KEY",)
return config
RETURN_TYPES = ("MESH", "MODEL_TASK_ID",)
RETURN_TYPES = ("STRING", "MODEL_TASK_ID",)
RETURN_NAMES = ("model_file", "model task_id")
FUNCTION = "generate_mesh"
CATEGORY = "TripoAPI"
@@ -195,7 +197,8 @@ class TripoAnimateRigNode:
config["required"]["apikey"] = ("API_KEY",)
return config
RETURN_TYPES = ("MESH", "RIG_TASK_ID")
RETURN_TYPES = ("STRING", "RIG_TASK_ID")
RETURN_NAMES = ("model_file", "rig task_id")
FUNCTION = "generate_mesh"
CATEGORY = "TripoAPI"
@@ -222,7 +225,8 @@ class TripoAnimateRetargetNode:
config["required"]["apikey"] = ("API_KEY",)
return config
RETURN_TYPES = ("MESH", "RETARGET_TASK_ID")
RETURN_TYPES = ("STRING", "RETARGET_TASK_ID")
RETURN_NAMES = ("model_file", "retarget task_id")
FUNCTION = "generate_mesh"
CATEGORY = "TripoAPI"
Regular → Executable
+7 -24
View File
@@ -72,12 +72,12 @@ class TripoAPI:
'task_id': None
}
def text_to_3d(self, prompt, model_version, texture, pbr, image_seed, model_seed, texture_seed, texture_quality, face_limit):
def text_to_3d(self, prompt, model_version, style, texture, pbr, image_seed, model_seed, texture_seed, texture_quality, face_limit, quad):
start_time = time.time()
param = {
"prompt": prompt
}
for param_name in ["model_version", "texture", "pbr", "image_seed", "model_seed", "texture_seed", "texture_quality", "face_limit"]:
for param_name in ["model_version", "style", "texture", "pbr", "image_seed", "model_seed", "texture_seed", "texture_quality", "face_limit", "quad"]:
_param = locals()[param_name]
if _param is not None:
param[param_name] = _param
@@ -87,7 +87,7 @@ class TripoAPI:
start_time)
return self._handle_task_response(response, start_time)
def image_to_3d(self, image_name, model_version, style, texture, pbr, model_seed, texture_seed, texture_quality, texture_alignment, face_limit):
def image_to_3d(self, image_name, model_version, style, texture, pbr, model_seed, texture_seed, texture_quality, texture_alignment, face_limit, quad):
start_time = time.time()
image_token = self.upload(image_name)
if isinstance(image_token, dict):
@@ -98,7 +98,7 @@ class TripoAPI:
"file_token": image_token
}
}
for param_name in ["model_version", "style", "texture", "pbr", "model_seed", "texture_seed", "texture_quality", "texture_alignment", "face_limit"]:
for param_name in ["model_version", "style", "texture", "pbr", "model_seed", "texture_seed", "texture_quality", "texture_alignment", "face_limit", "quad"]:
_param = locals()[param_name]
if _param is not None:
param[param_name] = _param
@@ -110,7 +110,7 @@ class TripoAPI:
start_time)
return self._handle_task_response(response, start_time)
def multiview_to_3d(self, image_names, model_version, texture, pbr, multiview_orth_proj, model_seed, texture_seed, texture_quality, texture_alignment, face_limit):
def multiview_to_3d(self, image_names, model_version, texture, pbr, multiview_orth_proj, model_seed, texture_seed, texture_quality, texture_alignment, face_limit, quad):
start_time = time.time()
image_tokens = []
for image_name in image_names:
@@ -125,27 +125,10 @@ class TripoAPI:
param = {"files":[]}
for image_token in image_tokens:
param["files"].append({"type": "jpg", "file_token": image_token})
for param_name in ["texture", "pbr", "texture_seed", "texture_quality", "texture_alignment", "face_limit"]:
for param_name in ["texture", "pbr", "texture_seed", "texture_quality", "texture_alignment", "face_limit", "quad"]:
_param = locals()[param_name]
if _param is not None:
param[param_name] = _param
else:
if image_tokens[1]:
mode = "LEFT"
index = 1
else:
mode = "RIGHT"
index = 3
param = {
"files": [
{"type": "jpg", "file_token": image_tokens[0]},
{"type": "jpg", "file_token": image_tokens[index]},
{"type": "jpg", "file_token": image_tokens[2]}
],
"mode": mode
}
if multiview_orth_proj is not None:
param["orthographic_projection"] = multiview_orth_proj
for param_name in ["model_seed", "model_version"]:
_param = locals()[param_name]
@@ -332,6 +315,6 @@ class TripoAPI:
with open(os.path.join(subfolder, file), "wb") as f:
f.write(response.content)
print(f"Saved GLB file to {subfolder}/{file}")
return {'status': 'success', 'model': {"sub_folder": subfolder, "filename": file}, 'task_id': task_id}
return {'status': 'success', 'model': os.path.join(subfolder, file), 'task_id': task_id}
else:
return {'status': 'error', 'message': 'Failed to download model', 'task_id': task_id}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 KiB

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 KiB

After

Width:  |  Height:  |  Size: 432 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 KiB

After

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 KiB

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 284 KiB