Skip to content

Commit 16279f2

Browse files
committed
fix workflow_convert
1 parent a323be9 commit 16279f2

2 files changed

Lines changed: 19 additions & 42 deletions

File tree

src/bizyair/data_types.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
STYLE_MODEL = "BIZYAIR_STYLE_MODEL"
1212

1313

14+
BIZYAIR_TYPE_MAP = {
15+
"MODEL": MODEL,
16+
"CLIP": CLIP,
17+
"VAE": VAE,
18+
"CONDITIONING": CONDITIONING,
19+
"CONTROL_NET": CONTROL_NET,
20+
"UPSCALE_MODEL": UPSCALE_MODEL,
21+
"INSTANTID": INSTANTID,
22+
"FACEANALYSIS": FACEANALYSIS,
23+
"STYLE_MODEL": STYLE_MODEL,
24+
}
25+
26+
1427
def is_model_datatype(datatype):
1528
return datatype in [MODEL, CLIP, VAE, CONDITIONING, CONTROL_NET, STYLE_MODEL]
1629

tools/convert_to_bizyair.py

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def load_input_file(file_path: str):
9393
setup_comfyui_env()
9494
initialize_comfyui()
9595
import bizyair
96+
from bizyair.data_types import BIZYAIR_TYPE_MAP
9697

9798

9899
def get_args():
@@ -111,8 +112,6 @@ def main():
111112
with open(args.output, "w") as f:
112113
json.dump(out, f)
113114

114-
# pprint.pprint({"status": "success"})
115-
116115

117116
def get_bizyair_display_name(class_type: str) -> str:
118117
bizyair_cls_prefix = bizyair.nodes_base.PREFIX
@@ -145,12 +144,15 @@ def workflow_convert(inputs: dict):
145144
if node_inputs:
146145
for input_node in node_inputs:
147146
input_type = input_node["type"]
148-
input_node["type"] = f"{bizyair.nodes_base.PREFIX}_{input_type}"
147+
input_node["type"] = BIZYAIR_TYPE_MAP.get("input_type", input_type)
149148

150149
if node_outputs:
151150
for output_node in node_outputs:
152151
output_type = output_node["type"]
153-
output_node["type"] = f"{bizyair.nodes_base.PREFIX}_{output_type}"
152+
output_node["type"] = BIZYAIR_TYPE_MAP.get(
153+
"output_type", output_type
154+
)
155+
154156
is_converted = True
155157
pprint.pprint(
156158
{
@@ -186,35 +188,6 @@ def workflow_api_convert(inputs: dict):
186188
return inputs
187189

188190

189-
def patch_apply(inputs: dict, yaml_file):
190-
replacements = load_yaml_replacements(yaml_file)
191-
for replacement in replacements["node_replacements"]:
192-
193-
original_type = replacement["original_type"]
194-
replace_type = replacement["replace_type"]
195-
196-
for node in inputs["nodes"]:
197-
if "type" in node and node["type"] == original_type:
198-
node["type"] = replace_type
199-
200-
display_name = get_bizyair_display_name(replace_type)
201-
node["properties"]["Node name for S&R"] = display_name
202-
203-
node_inputs = node.get("inputs")
204-
if node_inputs:
205-
for input_node in node_inputs:
206-
input_type = input_node["type"]
207-
input_node["type"] = f"{bizyair.nodes_base.PREFIX}_{input_type}"
208-
209-
node_outputs = node.get("outputs")
210-
if node_outputs:
211-
for output_node in node_outputs:
212-
output_type = output_node["type"]
213-
output_node["type"] = f"{bizyair.nodes_base.PREFIX}_{output_type}"
214-
215-
return inputs
216-
217-
218191
def convert_to_bizyair(inputs: dict, yaml_file):
219192
bizyair.NODE_CLASS_MAPPINGS
220193

@@ -224,17 +197,8 @@ def convert_to_bizyair(inputs: dict, yaml_file):
224197
elif input_format == "workflow":
225198
inputs = workflow_convert(inputs)
226199

227-
if yaml_file:
228-
inputs = patch_apply(inputs, yaml_file)
229-
230200
return inputs
231201

232202

233-
def load_yaml_replacements(yaml_file):
234-
with open(yaml_file, "r") as file:
235-
replacements = yaml.safe_load(file)
236-
return replacements
237-
238-
239203
if __name__ == "__main__":
240204
main()

0 commit comments

Comments
 (0)