Spaces:
Running on Zero
Running on Zero
refactor(controlnet): align Qwen-Image-2.1 with merged Fun ControlNet and bump upstream deps
Browse files
chain_injectors/controlnet_injector.py
CHANGED
|
@@ -28,10 +28,10 @@ def inject(assembler, chain_definition, chain_items):
|
|
| 28 |
default_megapixels = 1.0
|
| 29 |
megapixels = float(chain_definition.get('megapixels', default_megapixels))
|
| 30 |
|
| 31 |
-
# 1. Qwen-Image-2.1
|
| 32 |
-
if template_name
|
| 33 |
if 'model' not in assembler.workflow[ksampler_id]['inputs']:
|
| 34 |
-
print(f"Warning: KSampler node '{ksampler_name}' is missing 'model' input. Skipping
|
| 35 |
return
|
| 36 |
|
| 37 |
current_model_connection = assembler.workflow[ksampler_id]['inputs']['model']
|
|
@@ -57,19 +57,24 @@ def inject(assembler, chain_definition, chain_items):
|
|
| 57 |
apply_cn_id = assembler._get_unique_id()
|
| 58 |
apply_cn_node = assembler._get_node_template(template_name)
|
| 59 |
apply_cn_node['inputs']['strength'] = item_data.get('strength', 1.0)
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
apply_cn_node['inputs']['model'] = current_model_connection
|
| 63 |
apply_cn_node['inputs']['model_patch'] = [patch_loader_id, 0]
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
| 66 |
apply_cn_node['inputs']['vae'] = vae_connection
|
| 67 |
|
| 68 |
assembler.workflow[apply_cn_id] = apply_cn_node
|
| 69 |
current_model_connection = [apply_cn_id, 0]
|
| 70 |
|
| 71 |
assembler.workflow[ksampler_id]['inputs']['model'] = current_model_connection
|
| 72 |
-
print(f"
|
| 73 |
return
|
| 74 |
|
| 75 |
# 2. Anima LLLite ControlNet
|
|
|
|
| 28 |
default_megapixels = 1.0
|
| 29 |
megapixels = float(chain_definition.get('megapixels', default_megapixels))
|
| 30 |
|
| 31 |
+
# 1. Fun ControlNet (Qwen-Image-2.1)
|
| 32 |
+
if template_name in ("ZImageFunControlnet", "QwenImage21FunControlNetApply"):
|
| 33 |
if 'model' not in assembler.workflow[ksampler_id]['inputs']:
|
| 34 |
+
print(f"Warning: KSampler node '{ksampler_name}' is missing 'model' input. Skipping Fun ControlNet.")
|
| 35 |
return
|
| 36 |
|
| 37 |
current_model_connection = assembler.workflow[ksampler_id]['inputs']['model']
|
|
|
|
| 57 |
apply_cn_id = assembler._get_unique_id()
|
| 58 |
apply_cn_node = assembler._get_node_template(template_name)
|
| 59 |
apply_cn_node['inputs']['strength'] = item_data.get('strength', 1.0)
|
| 60 |
+
if 'start_percent' in apply_cn_node.get('inputs', {}):
|
| 61 |
+
apply_cn_node['inputs']['start_percent'] = item_data.get('start_percent', 0.0)
|
| 62 |
+
if 'end_percent' in apply_cn_node.get('inputs', {}):
|
| 63 |
+
apply_cn_node['inputs']['end_percent'] = item_data.get('end_percent', 1.0)
|
| 64 |
apply_cn_node['inputs']['model'] = current_model_connection
|
| 65 |
apply_cn_node['inputs']['model_patch'] = [patch_loader_id, 0]
|
| 66 |
+
if 'image' in apply_cn_node.get('inputs', {}):
|
| 67 |
+
apply_cn_node['inputs']['image'] = [image_scaler_id, 0]
|
| 68 |
+
elif 'control_image' in apply_cn_node.get('inputs', {}):
|
| 69 |
+
apply_cn_node['inputs']['control_image'] = [image_scaler_id, 0]
|
| 70 |
+
if vae_connection and 'vae' in apply_cn_node.get('inputs', {}):
|
| 71 |
apply_cn_node['inputs']['vae'] = vae_connection
|
| 72 |
|
| 73 |
assembler.workflow[apply_cn_id] = apply_cn_node
|
| 74 |
current_model_connection = [apply_cn_id, 0]
|
| 75 |
|
| 76 |
assembler.workflow[ksampler_id]['inputs']['model'] = current_model_connection
|
| 77 |
+
print(f"Fun ControlNet injector applied. KSampler model input redirected through {len(chain_items)} node(s).")
|
| 78 |
return
|
| 79 |
|
| 80 |
# 2. Anima LLLite ControlNet
|
comfy_integration/setup.py
CHANGED
|
@@ -25,12 +25,6 @@ def initialize_comfyui():
|
|
| 25 |
else:
|
| 26 |
print("✅ ComfyUI repository already exists.")
|
| 27 |
|
| 28 |
-
try:
|
| 29 |
-
print("--- [Setup] Applying PR #16519 for ComfyUI (Qwen-Image 2.1 Fun ControlNet) ---")
|
| 30 |
-
os.system(f"git -C {COMFYUI_TEMP_DIR} fetch --depth 1 origin pull/16519/head && git -c user.name=dev -c user.email=dev@example.com -C {COMFYUI_TEMP_DIR} merge --no-edit FETCH_HEAD || git -C {COMFYUI_TEMP_DIR} checkout -f FETCH_HEAD")
|
| 31 |
-
print("✅ Successfully applied PR #16519.")
|
| 32 |
-
except Exception as e:
|
| 33 |
-
print(f"⚠️ Warning: Could not apply PR #16519 for ComfyUI: {e}")
|
| 34 |
|
| 35 |
print(f"--- Merging ComfyUI from '{COMFYUI_TEMP_DIR}' to '{APP_DIR}' ---")
|
| 36 |
for item in os.listdir(COMFYUI_TEMP_DIR):
|
|
|
|
| 25 |
else:
|
| 26 |
print("✅ ComfyUI repository already exists.")
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
print(f"--- Merging ComfyUI from '{COMFYUI_TEMP_DIR}' to '{APP_DIR}' ---")
|
| 30 |
for item in os.listdir(COMFYUI_TEMP_DIR):
|
core/pipelines/workflow_recipes/_partials/conditioning/qwen-image-2.1.yaml
CHANGED
|
@@ -51,7 +51,7 @@ dynamic_lora_chains:
|
|
| 51 |
|
| 52 |
dynamic_controlnet_chains:
|
| 53 |
controlnet_chain:
|
| 54 |
-
template: "
|
| 55 |
ksampler_node: "ksampler"
|
| 56 |
vae_source: "vae_loader:0"
|
| 57 |
|
|
|
|
| 51 |
|
| 52 |
dynamic_controlnet_chains:
|
| 53 |
controlnet_chain:
|
| 54 |
+
template: "ZImageFunControlnet"
|
| 55 |
ksampler_node: "ksampler"
|
| 56 |
vae_source: "vae_loader:0"
|
| 57 |
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
comfyui-frontend-package==1.53.6
|
| 2 |
-
comfyui-workflow-templates==0.11.
|
| 3 |
comfyui-embedded-docs==0.5.12
|
| 4 |
torch
|
| 5 |
torchsde
|
|
@@ -21,7 +21,7 @@ alembic
|
|
| 21 |
SQLAlchemy>=2.0.0
|
| 22 |
filelock
|
| 23 |
av>=17.0.0
|
| 24 |
-
comfy-kitchen==0.2.
|
| 25 |
comfy-aimdo==0.5.5
|
| 26 |
requests
|
| 27 |
simpleeval>=1.0.0
|
|
|
|
| 1 |
comfyui-frontend-package==1.53.6
|
| 2 |
+
comfyui-workflow-templates==0.11.70
|
| 3 |
comfyui-embedded-docs==0.5.12
|
| 4 |
torch
|
| 5 |
torchsde
|
|
|
|
| 21 |
SQLAlchemy>=2.0.0
|
| 22 |
filelock
|
| 23 |
av>=17.0.0
|
| 24 |
+
comfy-kitchen==0.2.36
|
| 25 |
comfy-aimdo==0.5.5
|
| 26 |
requests
|
| 27 |
simpleeval>=1.0.0
|