Skip to content
This repository has been archived by the owner on Dec 29, 2024. It is now read-only.

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
peteromallet committed Feb 19, 2024
1 parent 596cfea commit 5f0a0f7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 41 deletions.
47 changes: 26 additions & 21 deletions utils/ml_processor/comfy_data_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def transform_sdxl_workflow(query: MLQueryObject):
workflow["10"]["inputs"]["steps"], workflow["10"]["inputs"]["cfg"] = steps, cfg
workflow["11"]["inputs"]["steps"], workflow["11"]["inputs"]["cfg"] = steps, cfg

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_sdxl_img2img_workflow(query: MLQueryObject):
Expand All @@ -78,7 +78,7 @@ def transform_sdxl_img2img_workflow(query: MLQueryObject):
workflow["42:2"]["inputs"]["denoise"] = 1 - strength
workflow["42:2"]["inputs"]["seed"] = random_seed()

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_sdxl_controlnet_workflow(query: MLQueryObject):
Expand All @@ -102,7 +102,7 @@ def transform_sdxl_controlnet_workflow(query: MLQueryObject):
workflow["3"]["inputs"]["steps"], workflow["3"]["inputs"]["cfg"] = steps, cfg
workflow["13"]["inputs"]["image"] = image_name

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_sdxl_controlnet_openpose_workflow(query: MLQueryObject):
Expand All @@ -124,7 +124,7 @@ def transform_sdxl_controlnet_openpose_workflow(query: MLQueryObject):
workflow["3"]["inputs"]["steps"], workflow["3"]["inputs"]["cfg"] = steps, cfg
workflow["12"]["inputs"]["image"] = image_name

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_llama_2_7b_workflow(query: MLQueryObject):
Expand All @@ -138,7 +138,7 @@ def transform_llama_2_7b_workflow(query: MLQueryObject):
workflow["15"]["inputs"]["prompt"] = input_text
workflow["15"]["inputs"]["temperature"] = temperature

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_sdxl_inpainting_workflow(query: MLQueryObject):
Expand Down Expand Up @@ -184,7 +184,7 @@ def transform_sdxl_inpainting_workflow(query: MLQueryObject):
workflow["34"]["inputs"]["text_g"] = workflow["34"]["inputs"]["text_l"] = positive_prompt
workflow["37"]["inputs"]["text_g"] = workflow["37"]["inputs"]["text_l"] = negative_prompt

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_ipadaptor_plus_workflow(query: MLQueryObject):
Expand All @@ -206,7 +206,7 @@ def transform_ipadaptor_plus_workflow(query: MLQueryObject):
workflow["7"]["inputs"]["text"] = query.negative_prompt
workflow["27"]["inputs"]["weight"] = query.strength

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_ipadaptor_face_workflow(query: MLQueryObject):
Expand All @@ -230,7 +230,7 @@ def transform_ipadaptor_face_workflow(query: MLQueryObject):
workflow["36"]["inputs"]["weight"] = query.strength
workflow["36"]["inputs"]["weight_v2"] = query.strength

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_ipadaptor_face_plus_workflow(query: MLQueryObject):
Expand All @@ -256,37 +256,40 @@ def transform_ipadaptor_face_plus_workflow(query: MLQueryObject):
workflow["29"]["inputs"]["weight"] = query.strength[0]
workflow["27"]["inputs"]["weight"] = query.strength[1]

return json.dumps(workflow), output_node_ids, [], []
return json.dumps(workflow), output_node_ids, []

@staticmethod
def transform_steerable_motion_workflow(query: MLQueryObject):

def update_json_with_loras(json_data, loras):
start_id = 536
new_ids = []

# Add LoRAs
for lora in loras:
new_id = str(start_id)
json_data[new_id] = {
"inputs": {
"lora_name": lora["filename"],
"lora_name": lora["lora_name"],
"strength": lora["lora_strength"],
"prev_motion_lora": [new_ids[-1] if new_ids else "", 0]
},
"class_type": "ADE_AnimateDiffLoRALoader",
"_meta": {
"title": "Load AnimateDiff LoRA 🎭🅐🅓"
}
}

if new_ids:
json_data[new_ids[-1]]['inputs']['prev_motion_lora'] = [new_id, 0]

if new_ids: # Update previous node's prev_motion_lora to point to this new node
json_data[new_ids[-1]]['inputs']['prev_motion_lora'][0] = new_id
new_ids.append(new_id)
start_id += 1

# Ensure the last node's prev_motion_lora is empty
if new_ids:
json_data[new_ids[-1]]['inputs']['prev_motion_lora'] = ["", 0]

# Update node 545 if needed and if there are new items
if "545" in json_data and len(new_ids):
if loras:
if "motion_lora" not in json_data["545"]["inputs"]:
# If "motion_lora" is not present, add it with the specified values
json_data["545"]["inputs"]["motion_lora"] = ["536", 0]
Expand All @@ -312,7 +315,7 @@ def update_json_with_loras(json_data, loras):
workflow['281']['inputs']['format'] = sm_data.get('output_format')
workflow['541']['inputs']['pre_text'] = sm_data.get('prompt')
workflow['543']['inputs']['pre_text'] = sm_data.get('negative_prompt')
workflow['292']['inputs']['multiplier'] = sm_data.get('stmfnet_multiplier')
workflow['559']['inputs']['multiplier'] = sm_data.get('stmfnet_multiplier')
workflow['558']['inputs']['relative_ipadapter_strength'] = sm_data.get('relative_ipadapter_strength')
workflow['558']['inputs']['relative_cn_strength'] = sm_data.get('relative_cn_strength')
workflow['558']['inputs']['type_of_strength_distribution'] = sm_data.get('type_of_strength_distribution')
Expand Down Expand Up @@ -342,11 +345,13 @@ def update_json_with_loras(json_data, loras):
workflow["543"]["inputs"]["text"] = sm_data.get('individual_negative_prompts')

# download the json file as text.json
# with open("text.json", "w") as f:
# f.write(json.dumps(workflow))
with open("text.json", "w") as f:
f.write(json.dumps(workflow))

ignore_list = sm_data.get("lora_data", [])
return json.dumps(workflow), output_node_ids, [], ignore_list


extra_model_lists = sm_data.get("lora_data", [])
return json.dumps(workflow), output_node_ids, extra_model_lists


# NOTE: only populating with models currently in use
Expand Down
39 changes: 19 additions & 20 deletions utils/ml_processor/comfy_workflows/steerable_motion_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"pingpong": false,
"save_output": true,
"images": [
"292",
"559",
0
]
},
Expand All @@ -59,22 +59,6 @@
"title": "Video Combine 🎥🅥🅗🅢"
}
},
"292": {
"inputs": {
"ckpt_name": "stmfnet.pth",
"clear_cache_after_n_frames": 15,
"multiplier": 2,
"duplicate_first_last_frames": true,
"frames": [
"354",
2
]
},
"class_type": "STMFNet VFI",
"_meta": {
"title": "STMFNet VFI"
}
},
"342": {
"inputs": {
"context_length": 16,
Expand Down Expand Up @@ -137,7 +121,7 @@
},
"401": {
"inputs": {
"directory": "./ComfyUI/input/",
"directory": "/workspace/ComfyUI/input//light_goes_on/",
"image_load_cap": 0,
"skip_first_images": 0,
"select_every_nth": 1
Expand Down Expand Up @@ -170,7 +154,7 @@
},
"461": {
"inputs": {
"ckpt_name": "Realistic_Vision_V5.1.safetensors"
"ckpt_name": "Realistic_Vision_V5.0.safetensors"
},
"class_type": "CheckpointLoaderSimple",
"_meta": {
Expand Down Expand Up @@ -438,7 +422,7 @@
},
"558": {
"inputs": {
"control_net_name": "v3_sd15_sparsectrl_rgb.ckpt",
"control_net_name": "SD1.5/animatediff/v3_sd15_sparsectrl_rgb.ckpt",
"type_of_frame_distribution": "linear",
"linear_frame_distribution_value": 16,
"dynamic_frame_distribution_values": "0,10,26,40",
Expand Down Expand Up @@ -486,5 +470,20 @@
"_meta": {
"title": "Batch Creative Interpolation 🎞️🅢🅜"
}
},
"559": {
"inputs": {
"ckpt_name": "film_net_fp32.pt",
"clear_cache_after_n_frames": 10,
"multiplier": 2,
"frames": [
"354",
2
]
},
"class_type": "FILM VFI",
"_meta": {
"title": "FILM VFI"
}
}
}

0 comments on commit 5f0a0f7

Please sign in to comment.