-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy paththreeDInferenceInputs.py
More file actions
75 lines (60 loc) · 2.48 KB
/
Copy paththreeDInferenceInputs.py
File metadata and controls
75 lines (60 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from .utils import runwareUtils as rwUtils
_IMAGE_SLOTS = 8
class threeDInferenceInputs:
"""3D Inference Inputs node for configuring 3D generation inputs"""
@classmethod
def INPUT_TYPES(cls):
optional = {
"image": ("IMAGE", {
"tooltip": "Input image for 3D inference. This image will be used as the source for generating the 3D model.",
}),
"mask": ("IMAGE", {
"tooltip": "Optional mask image to specify a region of interest in the input image for 3D generation.",
}),
"meshFile": ("STRING", {
"default": "",
"tooltip": "Base64 data URI of mesh file (.glb or .ply) from Runware Load Mesh.",
}),
}
for i in range(1, _IMAGE_SLOTS + 1):
optional[f"Images {i}"] = ("IMAGE", {
"tooltip": f"Multi-view image slot {i}; merged in order into inputs.images as a list of data URIs.",
})
return {
"required": {},
"optional": optional,
}
DESCRIPTION = (
"Configure custom inputs for Runware 3D Inference: image, mask, meshFile, and Images 1…Images 8 "
"(merged into inputs.images as an array)."
)
FUNCTION = "createInputs"
RETURN_TYPES = ("RUNWARE3DINFERENCEINPUTS",)
RETURN_NAMES = ("Inputs",)
CATEGORY = "Runware"
def createInputs(self, **kwargs):
"""Create 3D inference inputs from provided parameters"""
image = kwargs.get("image", None)
mask = kwargs.get("mask", None)
mesh_file = kwargs.get("meshFile", "")
inputs = {}
if image is not None:
inputs["image"] = rwUtils.convertTensor2IMG(image)
if mask is not None:
inputs["mask"] = rwUtils.convertTensor2IMG(mask)
if mesh_file and isinstance(mesh_file, str) and mesh_file.strip():
inputs["meshFile"] = mesh_file.strip()
images_list: list = []
for i in range(1, _IMAGE_SLOTS + 1):
slot = kwargs.get(f"Images {i}")
if slot is not None:
images_list.append(rwUtils.convertTensor2IMG(slot))
if images_list:
inputs["images"] = images_list
return (inputs,)
NODE_CLASS_MAPPINGS = {
"Runware3DInferenceInputs": threeDInferenceInputs,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"Runware3DInferenceInputs": "Runware 3D Inference Inputs",
}