Skip to content

Commit 9635c2e

Browse files
fix(api-nodes): make "obj" output optional in Hunyuan3D Text and Image to 3D (#13449)
Signed-off-by: bigcat88 <bigcat88@icloud.com> Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
1 parent f8d92cf commit 9635c2e

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

comfy_api_nodes/nodes_hunyuan3d.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,17 @@ async def execute(
221221
response_model=To3DProTaskResultResponse,
222222
status_extractor=lambda r: r.Status,
223223
)
224-
obj_result = await download_and_extract_obj_zip(get_file_from_response(result.ResultFile3Ds, "obj").Url)
224+
obj_file_response = get_file_from_response(result.ResultFile3Ds, "obj", raise_if_not_found=False)
225+
obj_result = None
226+
if obj_file_response:
227+
obj_result = await download_and_extract_obj_zip(obj_file_response.Url)
225228
return IO.NodeOutput(
226229
f"{task_id}.glb",
227230
await download_url_to_file_3d(
228231
get_file_from_response(result.ResultFile3Ds, "glb").Url, "glb", task_id=task_id
229232
),
230-
obj_result.obj,
231-
obj_result.texture,
233+
obj_result.obj if obj_result else None,
234+
obj_result.texture if obj_result else None,
232235
)
233236

234237

@@ -378,17 +381,30 @@ async def execute(
378381
response_model=To3DProTaskResultResponse,
379382
status_extractor=lambda r: r.Status,
380383
)
381-
obj_result = await download_and_extract_obj_zip(get_file_from_response(result.ResultFile3Ds, "obj").Url)
384+
obj_file_response = get_file_from_response(result.ResultFile3Ds, "obj", raise_if_not_found=False)
385+
if obj_file_response:
386+
obj_result = await download_and_extract_obj_zip(obj_file_response.Url)
387+
return IO.NodeOutput(
388+
f"{task_id}.glb",
389+
await download_url_to_file_3d(
390+
get_file_from_response(result.ResultFile3Ds, "glb").Url, "glb", task_id=task_id
391+
),
392+
obj_result.obj,
393+
obj_result.texture,
394+
obj_result.metallic if obj_result.metallic is not None else torch.zeros(1, 1, 1, 3),
395+
obj_result.normal if obj_result.normal is not None else torch.zeros(1, 1, 1, 3),
396+
obj_result.roughness if obj_result.roughness is not None else torch.zeros(1, 1, 1, 3),
397+
)
382398
return IO.NodeOutput(
383399
f"{task_id}.glb",
384400
await download_url_to_file_3d(
385401
get_file_from_response(result.ResultFile3Ds, "glb").Url, "glb", task_id=task_id
386402
),
387-
obj_result.obj,
388-
obj_result.texture,
389-
obj_result.metallic if obj_result.metallic is not None else torch.zeros(1, 1, 1, 3),
390-
obj_result.normal if obj_result.normal is not None else torch.zeros(1, 1, 1, 3),
391-
obj_result.roughness if obj_result.roughness is not None else torch.zeros(1, 1, 1, 3),
403+
None,
404+
None,
405+
None,
406+
None,
407+
None,
392408
)
393409

394410

0 commit comments

Comments
 (0)