RioShiina commited on
Commit
266f72f
·
verified ·
1 Parent(s): 166d6be

feat: add Qwen-Image-2.1 prompt enhancer

Browse files
README.md CHANGED
@@ -172,6 +172,8 @@ models:
172
  - Qwen/Qwen-Image
173
  - Qwen/Qwen-Image-2512
174
  - Qwen/Qwen-Image-2.1
 
 
175
  - Qwen/Qwen-Image-Edit
176
  - Qwen/Qwen-Image-Edit-2509
177
  - Qwen/Qwen-Image-Edit-2511
 
172
  - Qwen/Qwen-Image
173
  - Qwen/Qwen-Image-2512
174
  - Qwen/Qwen-Image-2.1
175
+ - Qwen/Qwen-Image-2.1-PE-I2I
176
+ - Qwen/Qwen-Image-2.1-PE-T2I
177
  - Qwen/Qwen-Image-Edit
178
  - Qwen/Qwen-Image-Edit-2509
179
  - Qwen/Qwen-Image-Edit-2511
chain_injectors/qwen_image_2_1_prompt_enhancer_injector.py ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Qwen-Image-2.1 Prompt Enhancer Chain Injector.
2
+
3
+ This injector automatically integrates the Qwen-Image-2.1 prompt enhancement model into
4
+ the generation workflow:
5
+ - Detects whether the task is pure text-to-image (T2I) or involves images (I2I, inpainting,
6
+ outpainting, hires.fix, or multi-reference images).
7
+ - Automatically selects the appropriate prompt enhancement checkpoint:
8
+ - T2I: qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors
9
+ - I2I / Reference: qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors
10
+ - Handles single or multi-reference inputs: multiple reference images are stitched into
11
+ a structured grid layout via ComfyUI native ImageStitch nodes and scaled via ImageScaleToTotalPixels.
12
+ - Supports reasoning mode (thinking=True) with automatic reasoning tag stripping via RegexReplace
13
+ (^.*?</think>\\s*) to prevent thought chain text from contaminating downstream image conditioning.
14
+ """
15
+
16
+ try:
17
+ from utils.app_utils import ensure_file_downloaded
18
+ except ImportError:
19
+ ensure_file_downloaded = None
20
+
21
+
22
+ def create_node(assembler, class_type, title):
23
+ """Create a workflow node dictionary with fallback template generation."""
24
+ try:
25
+ node = assembler._get_node_template(class_type)
26
+ except Exception:
27
+ node = {
28
+ "inputs": {},
29
+ "class_type": class_type,
30
+ "_meta": {"title": title}
31
+ }
32
+ if "_meta" not in node:
33
+ node["_meta"] = {}
34
+ node['_meta']['title'] = title
35
+ return node
36
+
37
+
38
+ def inject(assembler, chain_definition, chain_items):
39
+ """Inject Qwen-Image-2.1 prompt enhancer nodes into the target generation workflow."""
40
+ if not chain_items:
41
+ return
42
+
43
+ is_enabled = False
44
+ thinking_enabled = False
45
+ max_length = 512
46
+ for item in chain_items:
47
+ if isinstance(item, dict):
48
+ if item.get("enable", False) or item.get("enabled", False) or item.get("value", False):
49
+ is_enabled = True
50
+ if item.get("thinking", False) in (True, "true", "on", "yes", "1", 1):
51
+ thinking_enabled = True
52
+ if "max_length" in item and item["max_length"]:
53
+ try:
54
+ max_length = int(item["max_length"])
55
+ except (ValueError, TypeError):
56
+ pass
57
+ elif item is True or str(item).lower() in ("on", "true", "yes", "1"):
58
+ is_enabled = True
59
+ break
60
+
61
+ if not is_enabled:
62
+ return
63
+
64
+ target_node_name = chain_definition.get('target_node', 'prompt')
65
+ target_node_id = assembler.node_map.get(target_node_name)
66
+
67
+ if not target_node_id or target_node_id not in assembler.workflow:
68
+ for node_id, node in assembler.workflow.items():
69
+ if isinstance(node, dict) and node.get('class_type') == 'TextEncodeQwenImage21':
70
+ target_node_id = node_id
71
+ break
72
+
73
+ if not target_node_id or target_node_id not in assembler.workflow:
74
+ print(f"Warning: Target node '{target_node_name}' (TextEncodeQwenImage21) not found for Qwen-Image-2.1 Prompt Enhancer. Skipping.")
75
+ return
76
+
77
+ target_node = assembler.workflow[target_node_id]
78
+ original_prompt = target_node.get('inputs', {}).get('prompt', '')
79
+
80
+ # 1. Check if any LoadImage nodes exist in the workflow
81
+ load_image_nodes = [
82
+ node_id for node_id, node in assembler.workflow.items()
83
+ if isinstance(node, dict) and node.get('class_type') == 'LoadImage'
84
+ ]
85
+ has_load_image = len(load_image_nodes) > 0
86
+
87
+ target_image_conn = None
88
+
89
+ if not has_load_image:
90
+ # Pure text-to-image (txt2img) task without reference images
91
+ clip_model_name = "qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors"
92
+ else:
93
+ # Task with reference images or img2img / inpaint / outpaint / hires.fix
94
+ clip_model_name = "qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors"
95
+
96
+ # Collect image connections
97
+ # Prioritize extracting all images.image_* slots from target_node['inputs'] (injected by reference image injectors)
98
+ indexed_slots = []
99
+ target_inputs = target_node.get('inputs', {})
100
+ for slot_key, slot_val in target_inputs.items():
101
+ if slot_key.startswith('images.image_') and isinstance(slot_val, (list, tuple)):
102
+ try:
103
+ idx = int(slot_key.split('_')[-1])
104
+ except Exception:
105
+ idx = 999
106
+ indexed_slots.append((idx, slot_val))
107
+
108
+ indexed_slots.sort(key=lambda x: x[0])
109
+ ref_image_conns = [s[1] for s in indexed_slots]
110
+
111
+ # If no reference image slots exist (e.g. pure img2img / inpaint / outpaint), retrieve from LoadImage nodes
112
+ if not ref_image_conns:
113
+ for lid in load_image_nodes:
114
+ scaled_conn = None
115
+ for nid, node in assembler.workflow.items():
116
+ if isinstance(node, dict) and node.get('class_type') == 'ImageScaleToTotalPixels':
117
+ img_input = node.get('inputs', {}).get('image')
118
+ if isinstance(img_input, (list, tuple)) and str(img_input[0]) == str(lid):
119
+ scaled_conn = [nid, 0]
120
+ break
121
+ if scaled_conn:
122
+ ref_image_conns.append(scaled_conn)
123
+ else:
124
+ scale_id = assembler._get_unique_id()
125
+ scale_node = create_node(assembler, "ImageScaleToTotalPixels", "Scale Input Image")
126
+ scale_node['inputs'] = {
127
+ "upscale_method": "nearest-exact",
128
+ "megapixels": 1,
129
+ "resolution_steps": 1,
130
+ "image": [lid, 0]
131
+ }
132
+ assembler.workflow[scale_id] = scale_node
133
+ ref_image_conns.append([scale_id, 0])
134
+
135
+ # Organize multiple reference images into grid stitching
136
+ if len(ref_image_conns) == 1:
137
+ target_image_conn = ref_image_conns[0]
138
+ elif len(ref_image_conns) >= 2:
139
+ num_cols = 2 if len(ref_image_conns) <= 4 else 3
140
+
141
+ rows = []
142
+ for i in range(0, len(ref_image_conns), num_cols):
143
+ rows.append(ref_image_conns[i:i + num_cols])
144
+
145
+ # Horizontally stitch images in each row
146
+ stitched_rows = []
147
+ for r_idx, row_imgs in enumerate(rows):
148
+ if len(row_imgs) == 1:
149
+ stitched_rows.append(row_imgs[0])
150
+ else:
151
+ curr_stitch = row_imgs[0]
152
+ for c_idx in range(1, len(row_imgs)):
153
+ st_id = assembler._get_unique_id()
154
+ st_node = create_node(assembler, "ImageStitch", f"Stitch Images (Row {r_idx+1}-{c_idx})")
155
+ st_node['inputs'] = {
156
+ "direction": "right",
157
+ "match_image_size": True,
158
+ "spacing_width": 0,
159
+ "spacing_color": "white",
160
+ "image1": curr_stitch,
161
+ "image2": row_imgs[c_idx]
162
+ }
163
+ assembler.workflow[st_id] = st_node
164
+ curr_stitch = [st_id, 0]
165
+ stitched_rows.append(curr_stitch)
166
+
167
+ # Vertically stitch multiple rows
168
+ if len(stitched_rows) == 1:
169
+ final_stitched = stitched_rows[0]
170
+ else:
171
+ curr_vertical = stitched_rows[0]
172
+ for r_idx in range(1, len(stitched_rows)):
173
+ st_id = assembler._get_unique_id()
174
+ st_node = create_node(assembler, "ImageStitch", f"Stitch Images (Vertical {r_idx})")
175
+ st_node['inputs'] = {
176
+ "direction": "down",
177
+ "match_image_size": True,
178
+ "spacing_width": 0,
179
+ "spacing_color": "white",
180
+ "image1": curr_vertical,
181
+ "image2": stitched_rows[r_idx]
182
+ }
183
+ assembler.workflow[st_id] = st_node
184
+ curr_vertical = [st_id, 0]
185
+ final_stitched = curr_vertical
186
+
187
+ # Scale final stitched image to ~1024 level via ImageScaleToTotalPixels
188
+ final_scale_id = assembler._get_unique_id()
189
+ final_scale_node = create_node(assembler, "ImageScaleToTotalPixels", "Scale Stitched Image")
190
+ final_scale_node['inputs'] = {
191
+ "upscale_method": "nearest-exact",
192
+ "megapixels": 1,
193
+ "resolution_steps": 1,
194
+ "image": final_stitched
195
+ }
196
+ assembler.workflow[final_scale_id] = final_scale_node
197
+ target_image_conn = [final_scale_id, 0]
198
+
199
+ # 2. Ensure model is downloaded in CPU stage before workflow execution
200
+ if ensure_file_downloaded:
201
+ try:
202
+ ensure_file_downloaded(clip_model_name)
203
+ except Exception as e:
204
+ print(f"Warning: Failed to ensure '{clip_model_name}' downloaded: {e}")
205
+
206
+ # 2. Create CLIPLoader node
207
+ clip_node_id = assembler._get_unique_id()
208
+ clip_node = create_node(assembler, "CLIPLoader", "Load CLIP")
209
+ clip_node['inputs'] = {
210
+ "clip_name": clip_model_name,
211
+ "type": "qwen_image",
212
+ "device": "default"
213
+ }
214
+ assembler.workflow[clip_node_id] = clip_node
215
+
216
+ # 3. Create TextGenerate node
217
+ text_gen_node_id = assembler._get_unique_id()
218
+ text_gen_node = create_node(assembler, "TextGenerate", "Generate Text")
219
+ text_gen_inputs = {
220
+ "prompt": original_prompt,
221
+ "max_length": max_length,
222
+ "sampling_mode": "on",
223
+ "sampling_mode.temperature": 0.7,
224
+ "sampling_mode.top_k": 20,
225
+ "sampling_mode.top_p": 0.95,
226
+ "sampling_mode.min_p": 0.0,
227
+ "sampling_mode.repetition_penalty": 1.05,
228
+ "sampling_mode.seed": 0,
229
+ "sampling_mode.presence_penalty": 0.0 if has_load_image else 1.5,
230
+ "thinking": thinking_enabled,
231
+ "use_default_template": True,
232
+ "mtp": "auto",
233
+ "clip": [clip_node_id, 0]
234
+ }
235
+ if target_image_conn is not None:
236
+ text_gen_inputs["image"] = target_image_conn
237
+
238
+ text_gen_node['inputs'] = text_gen_inputs
239
+ assembler.workflow[text_gen_node_id] = text_gen_node
240
+
241
+ # 4. Insert Replace Text (Regex) node if thinking is enabled to strip reasoning tags
242
+ if thinking_enabled:
243
+ regex_node_id = assembler._get_unique_id()
244
+ regex_node = create_node(assembler, "RegexReplace", "Replace Text (Regex)")
245
+ regex_node['inputs'] = {
246
+ "string": [text_gen_node_id, 0],
247
+ "regex_pattern": "^.*?</think>\\s*",
248
+ "replace": "",
249
+ "case_insensitive": True,
250
+ "multiline": False,
251
+ "dotall": True,
252
+ "count": 0
253
+ }
254
+ assembler.workflow[regex_node_id] = regex_node
255
+ target_node['inputs']['prompt'] = [regex_node_id, 0]
256
+ print(f"[Injector] Qwen-Image-2.1 Prompt Enhancer applied successfully with RegexReplace ({'I2I' if has_load_image else 'T2I'}, clip='{clip_model_name}', thinking=True).")
257
+ else:
258
+ target_node['inputs']['prompt'] = [text_gen_node_id, 0]
259
+ print(f"[Injector] Qwen-Image-2.1 Prompt Enhancer applied successfully ({'I2I' if has_load_image else 'T2I'}, clip='{clip_model_name}', thinking=False).")
core/model_manager.py CHANGED
@@ -1,8 +1,8 @@
1
  import gc
2
  from typing import List
3
  import gradio as gr
4
- from utils.app_utils import _ensure_model_downloaded
5
- from core.settings import ALL_MODEL_MAP
6
 
7
  class ModelManager:
8
  _instance = None
@@ -20,13 +20,20 @@ class ModelManager:
20
 
21
  def ensure_models_downloaded(self, required_models: List[str], progress):
22
  print(f"--- [ModelManager] Ensuring models are downloaded: {required_models} ---")
23
- for i, display_name in enumerate(required_models):
 
 
24
  if progress and hasattr(progress, '__call__'):
25
- progress(i / max(len(required_models), 1), desc=f"Checking file: {display_name}")
26
  try:
27
- _ensure_model_downloaded(display_name, progress)
 
 
 
 
 
28
  except Exception as e:
29
- raise gr.Error(f"Failed to download model '{display_name}'. Reason: {e}")
30
  print(f"--- [ModelManager] ✅ All required models are present on disk. ---")
31
 
32
  model_manager = ModelManager()
 
1
  import gc
2
  from typing import List
3
  import gradio as gr
4
+ from utils.app_utils import _ensure_model_downloaded, ensure_file_downloaded
5
+ from core.settings import ALL_MODEL_MAP, ALL_FILE_DOWNLOAD_MAP
6
 
7
  class ModelManager:
8
  _instance = None
 
20
 
21
  def ensure_models_downloaded(self, required_models: List[str], progress):
22
  print(f"--- [ModelManager] Ensuring models are downloaded: {required_models} ---")
23
+ for i, item in enumerate(required_models):
24
+ if not item:
25
+ continue
26
  if progress and hasattr(progress, '__call__'):
27
+ progress(i / max(len(required_models), 1), desc=f"Checking file: {item}")
28
  try:
29
+ if item in ALL_MODEL_MAP:
30
+ _ensure_model_downloaded(item, progress)
31
+ elif item in ALL_FILE_DOWNLOAD_MAP:
32
+ ensure_file_downloaded(item, progress)
33
+ else:
34
+ _ensure_model_downloaded(item, progress)
35
  except Exception as e:
36
+ raise gr.Error(f"Failed to download model '{item}'. Reason: {e}")
37
  print(f"--- [ModelManager] ✅ All required models are present on disk. ---")
38
 
39
  model_manager = ModelManager()
core/pipelines/pipeline_input_processor.py CHANGED
@@ -457,6 +457,15 @@ def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, wo
457
  "x": int(xs[i]), "y": int(ys[i]), "strength": float(strengths[i])
458
  })
459
 
 
 
 
 
 
 
 
 
 
460
  return {
461
  "active_loras_for_gpu": active_loras_for_gpu,
462
  "active_loras_for_meta": active_loras_for_meta,
@@ -477,5 +486,6 @@ def process_pipeline_inputs(ui_inputs: Dict[str, Any], progress: gr.Progress, wo
477
  "active_qwen_image_edit": active_qwen_image_edit,
478
  "active_reference_images": active_reference_images,
479
  "active_conditioning": active_conditioning,
 
480
  "temp_files_to_clean": temp_files_to_clean
481
  }
 
457
  "x": int(xs[i]), "y": int(ys[i]), "strength": float(strengths[i])
458
  })
459
 
460
+ pe_enable = ui_inputs.get('qwen_image_2_1_prompt_enhancer_enable', False)
461
+ active_qwen_image_2_1_prompt_enhancer = []
462
+ if 'qwen_image_2_1_prompt_enhancer' in enabled_chains and pe_enable:
463
+ active_qwen_image_2_1_prompt_enhancer.append({
464
+ "enable": True,
465
+ "thinking": bool(ui_inputs.get('qwen_image_2_1_prompt_enhancer_thinking', False)),
466
+ "max_length": int(ui_inputs.get('qwen_image_2_1_prompt_enhancer_max_length', 512))
467
+ })
468
+
469
  return {
470
  "active_loras_for_gpu": active_loras_for_gpu,
471
  "active_loras_for_meta": active_loras_for_meta,
 
486
  "active_qwen_image_edit": active_qwen_image_edit,
487
  "active_reference_images": active_reference_images,
488
  "active_conditioning": active_conditioning,
489
+ "active_qwen_image_2_1_prompt_enhancer": active_qwen_image_2_1_prompt_enhancer,
490
  "temp_files_to_clean": temp_files_to_clean
491
  }
core/pipelines/sd_image_pipeline.py CHANGED
@@ -122,6 +122,7 @@ class SdImagePipeline(BasePipeline):
122
  active_qwen_image_edit = processed.get("active_qwen_image_edit", [])
123
  active_reference_images = processed.get("active_reference_images", [])
124
  active_conditioning = processed["active_conditioning"]
 
125
 
126
  loras_string = f"LoRAs: [{', '.join(active_loras_for_meta)}]" if active_loras_for_meta else ""
127
 
@@ -182,6 +183,7 @@ class SdImagePipeline(BasePipeline):
182
  "krea2_style_reference_chain": active_krea2_reference_edit,
183
  "qwen_image_edit_chain": active_qwen_image_edit,
184
  "reference_image_chain": active_reference_images,
 
185
  "vae_chain": [ui_inputs.get('vae_name')] if (ui_inputs.get('vae_name') and 'vae' in enabled_chains) else [],
186
  "hidream_o1_smoothing_chain": hidream_o1_smoothing_data,
187
  "pid_chain": [ui_inputs.get('pid_settings', 'OFF')] if is_pid_enabled else [],
@@ -213,6 +215,18 @@ class SdImagePipeline(BasePipeline):
213
  workflow_inputs['height'] = ui_inputs['height']
214
 
215
  workflow = assembler.assemble(workflow_inputs)
 
 
 
 
 
 
 
 
 
 
 
 
216
 
217
  progress(1.0, desc="All models ready. Requesting GPU for generation...")
218
 
 
122
  active_qwen_image_edit = processed.get("active_qwen_image_edit", [])
123
  active_reference_images = processed.get("active_reference_images", [])
124
  active_conditioning = processed["active_conditioning"]
125
+ active_qwen_image_2_1_prompt_enhancer = processed.get("active_qwen_image_2_1_prompt_enhancer", [])
126
 
127
  loras_string = f"LoRAs: [{', '.join(active_loras_for_meta)}]" if active_loras_for_meta else ""
128
 
 
183
  "krea2_style_reference_chain": active_krea2_reference_edit,
184
  "qwen_image_edit_chain": active_qwen_image_edit,
185
  "reference_image_chain": active_reference_images,
186
+ "qwen_image_2_1_prompt_enhancer_chain": active_qwen_image_2_1_prompt_enhancer,
187
  "vae_chain": [ui_inputs.get('vae_name')] if (ui_inputs.get('vae_name') and 'vae' in enabled_chains) else [],
188
  "hidream_o1_smoothing_chain": hidream_o1_smoothing_data,
189
  "pid_chain": [ui_inputs.get('pid_settings', 'OFF')] if is_pid_enabled else [],
 
215
  workflow_inputs['height'] = ui_inputs['height']
216
 
217
  workflow = assembler.assemble(workflow_inputs)
218
+
219
+ post_assembled_models = []
220
+ for node_id, node in workflow.items():
221
+ if not isinstance(node, dict):
222
+ continue
223
+ inputs = node.get('inputs', {})
224
+ for k, v in inputs.items():
225
+ if isinstance(v, str) and v in ALL_FILE_DOWNLOAD_MAP:
226
+ if v not in required_models and v not in post_assembled_models:
227
+ post_assembled_models.append(v)
228
+ if post_assembled_models:
229
+ self.model_manager.ensure_models_downloaded(post_assembled_models, progress=progress)
230
 
231
  progress(1.0, desc="All models ready. Requesting GPU for generation...")
232
 
core/pipelines/workflow_recipes/_partials/conditioning/qwen-image-2.1.yaml CHANGED
@@ -70,6 +70,10 @@ dynamic_reference_image_chains:
70
  vae_node: "vae_loader"
71
  max_images: 10
72
 
 
 
 
 
73
  ui_map:
74
  positive_prompt: "prompt:prompt"
75
  negative_prompt: "prompt:negative_prompt"
 
70
  vae_node: "vae_loader"
71
  max_images: 10
72
 
73
+ dynamic_qwen_image_2_1_prompt_enhancer_chains:
74
+ qwen_image_2_1_prompt_enhancer_chain:
75
+ target_node: "prompt"
76
+
77
  ui_map:
78
  positive_prompt: "prompt:prompt"
79
  negative_prompt: "prompt:negative_prompt"
mcp_tools/common.py CHANGED
@@ -670,6 +670,16 @@ def _execute_imagegen_pipeline(task_id: str, params: dict):
670
  if isinstance(is_enabled, str):
671
  is_enabled = is_enabled.upper() in ("ON", "TRUE", "1")
672
  ui_inputs["pid_settings"] = "ON" if is_enabled else "OFF"
 
 
 
 
 
 
 
 
 
 
673
  elif itype == "krea2_identity_edit":
674
  img = _parse_image_param(item.get("image"))
675
  if img:
@@ -773,6 +783,19 @@ def _execute_imagegen_pipeline(task_id: str, params: dict):
773
  else:
774
  ui_inputs["pid_settings"] = "OFF"
775
 
 
 
 
 
 
 
 
 
 
 
 
 
 
776
  _TASKS_DB[task_id]["progress"] = 50
777
 
778
  # Execute Pipeline
 
670
  if isinstance(is_enabled, str):
671
  is_enabled = is_enabled.upper() in ("ON", "TRUE", "1")
672
  ui_inputs["pid_settings"] = "ON" if is_enabled else "OFF"
673
+ elif itype == "qwen_image_2_1_prompt_enhancer":
674
+ is_enabled = item.get("enable", item.get("enabled", True))
675
+ if isinstance(is_enabled, str):
676
+ is_enabled = is_enabled.upper() in ("ON", "TRUE", "1")
677
+ ui_inputs["qwen_image_2_1_prompt_enhancer_enable"] = bool(is_enabled)
678
+ is_thinking = item.get("thinking", False)
679
+ if isinstance(is_thinking, str):
680
+ is_thinking = is_thinking.upper() in ("ON", "TRUE", "1")
681
+ ui_inputs["qwen_image_2_1_prompt_enhancer_thinking"] = bool(is_thinking)
682
+ ui_inputs["qwen_image_2_1_prompt_enhancer_max_length"] = int(item.get("max_length", 512))
683
  elif itype == "krea2_identity_edit":
684
  img = _parse_image_param(item.get("image"))
685
  if img:
 
783
  else:
784
  ui_inputs["pid_settings"] = "OFF"
785
 
786
+ pe_val = params.get("qwen_image_2_1_prompt_enhancer") or params.get("qwen_image_2_1_prompt_enhancer_enable")
787
+ if pe_val is not None:
788
+ if isinstance(pe_val, bool):
789
+ ui_inputs["qwen_image_2_1_prompt_enhancer_enable"] = pe_val
790
+ elif isinstance(pe_val, dict):
791
+ ui_inputs["qwen_image_2_1_prompt_enhancer_enable"] = bool(pe_val.get("enable", pe_val.get("enabled", True)))
792
+ ui_inputs["qwen_image_2_1_prompt_enhancer_thinking"] = bool(pe_val.get("thinking", False))
793
+ ui_inputs["qwen_image_2_1_prompt_enhancer_max_length"] = int(pe_val.get("max_length", 512))
794
+ elif str(pe_val).upper() in ("ON", "TRUE", "1"):
795
+ ui_inputs["qwen_image_2_1_prompt_enhancer_enable"] = True
796
+ else:
797
+ ui_inputs["qwen_image_2_1_prompt_enhancer_enable"] = False
798
+
799
  _TASKS_DB[task_id]["progress"] = 50
800
 
801
  # Execute Pipeline
ui/events/change_handlers.py CHANGED
@@ -18,7 +18,7 @@ from .config_loaders import (
18
  load_ipadapter_config
19
  )
20
 
21
- def make_update_fn(m_comp, cat_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None):
22
  def update_fn(*args):
23
  arch = args[0]
24
  category = args[1]
@@ -90,6 +90,7 @@ def make_update_fn(m_comp, cat_comp, ar_comp, width_comp, height_comp, cn_types,
90
  if ref_img_acc: updates[ref_img_acc] = gr.update(visible=('reference_image' in enabled_chains))
91
  if pid_acc: updates[pid_acc] = gr.update(visible=('pid' in enabled_chains))
92
  if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))
 
93
 
94
  if ar_comp:
95
  res_key = arch_model_type
@@ -157,7 +158,7 @@ def make_update_fn(m_comp, cat_comp, ar_comp, width_comp, height_comp, cn_types,
157
  return update_fn
158
 
159
 
160
- def make_model_change_fn(cat_comp_ref, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None):
161
  def change_fn(*args):
162
  model_name = args[0]
163
  idx = 1
@@ -237,6 +238,7 @@ def make_model_change_fn(cat_comp_ref, ar_comp, width_comp, height_comp, cn_type
237
  if ref_img_acc: updates[ref_img_acc] = gr.update(visible=('reference_image' in enabled_chains))
238
  if pid_acc: updates[pid_acc] = gr.update(visible=('pid' in enabled_chains))
239
  if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))
 
240
 
241
  if ar_comp:
242
  res_key = arch_model_type
 
18
  load_ipadapter_config
19
  )
20
 
21
+ def make_update_fn(m_comp, cat_comp, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None, qwen_pe_acc=None):
22
  def update_fn(*args):
23
  arch = args[0]
24
  category = args[1]
 
90
  if ref_img_acc: updates[ref_img_acc] = gr.update(visible=('reference_image' in enabled_chains))
91
  if pid_acc: updates[pid_acc] = gr.update(visible=('pid' in enabled_chains))
92
  if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))
93
+ if qwen_pe_acc: updates[qwen_pe_acc] = gr.update(visible=('qwen_image_2_1_prompt_enhancer' in enabled_chains))
94
 
95
  if ar_comp:
96
  res_key = arch_model_type
 
158
  return update_fn
159
 
160
 
161
+ def make_model_change_fn(cat_comp_ref, ar_comp, width_comp, height_comp, cn_types, cn_series, cn_filepaths, anima_cn_types, anima_cn_series, anima_cn_filepaths, diffsynth_cn_types, diffsynth_cn_series, diffsynth_cn_filepaths, krea2_cn_types, krea2_cn_series, krea2_cn_filepaths, arch_comp_ref, ipa_preset, lora_acc, cn_acc, anima_cn_acc, diffsynth_cn_acc, krea2_cn_acc, ipa_acc, sd3_ipa_acc, flux1_ipa_acc, style_acc, embed_acc, cond_acc, ref_latent_acc, hidream_o1_ref_acc, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp, pid_acc=None, vae_acc=None, joyai_ref_acc=None, krea2_identity_edit_acc=None, krea2_reference_edit_acc=None, qwen_image_edit_acc=None, ref_img_acc=None, sensenova_ref_acc=None, task_type=None, type_comp=None, qwen_pe_acc=None):
162
  def change_fn(*args):
163
  model_name = args[0]
164
  idx = 1
 
238
  if ref_img_acc: updates[ref_img_acc] = gr.update(visible=('reference_image' in enabled_chains))
239
  if pid_acc: updates[pid_acc] = gr.update(visible=('pid' in enabled_chains))
240
  if vae_acc: updates[vae_acc] = gr.update(visible=('vae' in enabled_chains))
241
+ if qwen_pe_acc: updates[qwen_pe_acc] = gr.update(visible=('qwen_image_2_1_prompt_enhancer' in enabled_chains))
242
 
243
  if ar_comp:
244
  res_key = arch_model_type
ui/events/main.py CHANGED
@@ -80,6 +80,7 @@ def attach_event_handlers(ui_components, demo):
80
  ref_img_accordion = ui_components.get(f'reference_image_accordion_{prefix}')
81
  pid_accordion = ui_components.get(f'pid_accordion_{prefix}')
82
  vae_accordion = ui_components.get(f'vae_accordion_{prefix}')
 
83
 
84
  ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}')
85
 
@@ -121,6 +122,7 @@ def attach_event_handlers(ui_components, demo):
121
  if ref_img_accordion: outputs.append(ref_img_accordion)
122
  if pid_accordion: outputs.append(pid_accordion)
123
  if vae_accordion: outputs.append(vae_accordion)
 
124
  if ipa_preset_list: outputs.append(ipa_preset_list)
125
 
126
  outputs.extend(valid_extra_comps)
@@ -134,7 +136,7 @@ def attach_event_handlers(ui_components, demo):
134
  ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, krea2_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
135
  ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
136
  pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
137
- task_type=task_type, type_comp=type_comp
138
  )
139
  inputs = [arch_comp, cat_comp]
140
  if aspect_ratio_comp:
@@ -174,6 +176,7 @@ def attach_event_handlers(ui_components, demo):
174
  if ref_img_accordion: outputs2.append(ref_img_accordion)
175
  if pid_accordion: outputs2.append(pid_accordion)
176
  if vae_accordion: outputs2.append(vae_accordion)
 
177
  if ipa_preset_list: outputs2.append(ipa_preset_list)
178
 
179
  outputs2.extend(valid_extra_comps)
@@ -192,7 +195,7 @@ def attach_event_handlers(ui_components, demo):
192
  arch_comp, ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, krea2_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
193
  ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
194
  pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
195
- task_type=task_type, type_comp=type_comp
196
  )
197
  if type_comp:
198
  inputs2.append(type_comp)
@@ -286,6 +289,7 @@ def attach_event_handlers(ui_components, demo):
286
  f'krea2_reference_edit_accordion_{prefix}': 'krea2_style_reference',
287
  f'qwen_image_edit_accordion_{prefix}': 'qwen_image_edit',
288
  f'reference_image_accordion_{prefix}': 'reference_image',
 
289
  f'pid_accordion_{prefix}': 'pid',
290
  f'vae_accordion_{prefix}': 'vae',
291
  }
@@ -323,7 +327,9 @@ def attach_event_handlers(ui_components, demo):
323
  'hidream_o1_reference_accordion_imagegen', 'sensenova_reference_accordion_imagegen', 'joyai_reference_accordion_imagegen',
324
  'krea2_identity_edit_accordion_imagegen', 'krea2_reference_edit_accordion_imagegen',
325
  'qwen_image_edit_accordion_imagegen',
326
- 'reference_image_accordion_imagegen', 'pid_accordion_imagegen', 'vae_accordion_imagegen',
 
 
327
  ]
328
  for key in accordion_keys:
329
  if key in ui_components:
 
80
  ref_img_accordion = ui_components.get(f'reference_image_accordion_{prefix}')
81
  pid_accordion = ui_components.get(f'pid_accordion_{prefix}')
82
  vae_accordion = ui_components.get(f'vae_accordion_{prefix}')
83
+ qwen_pe_accordion = ui_components.get(f'qwen_image_2_1_prompt_enhancer_accordion_{prefix}')
84
 
85
  ipa_preset_list = ui_components.get(f'ipadapter_final_preset_{prefix}')
86
 
 
122
  if ref_img_accordion: outputs.append(ref_img_accordion)
123
  if pid_accordion: outputs.append(pid_accordion)
124
  if vae_accordion: outputs.append(vae_accordion)
125
+ if qwen_pe_accordion: outputs.append(qwen_pe_accordion)
126
  if ipa_preset_list: outputs.append(ipa_preset_list)
127
 
128
  outputs.extend(valid_extra_comps)
 
136
  ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, krea2_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
137
  ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
138
  pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
139
+ task_type=task_type, type_comp=type_comp, qwen_pe_acc=qwen_pe_accordion
140
  )
141
  inputs = [arch_comp, cat_comp]
142
  if aspect_ratio_comp:
 
176
  if ref_img_accordion: outputs2.append(ref_img_accordion)
177
  if pid_accordion: outputs2.append(pid_accordion)
178
  if vae_accordion: outputs2.append(vae_accordion)
179
+ if qwen_pe_accordion: outputs2.append(qwen_pe_accordion)
180
  if ipa_preset_list: outputs2.append(ipa_preset_list)
181
 
182
  outputs2.extend(valid_extra_comps)
 
195
  arch_comp, ipa_preset_list, lora_accordion, cn_accordion, anima_cn_accordion, diffsynth_cn_accordion, krea2_cn_accordion, ipa_accordion, sd3_ipa_accordion, flux1_ipa_accordion, style_accordion, embedding_accordion, conditioning_accordion,
196
  ref_latent_accordion, hidream_o1_ref_accordion, prompt_comp, neg_prompt_comp, steps_comp, cfg_comp, sampler_comp, scheduler_comp,
197
  pid_acc=pid_accordion, vae_acc=vae_accordion, joyai_ref_acc=joyai_ref_accordion, krea2_identity_edit_acc=krea2_identity_edit_accordion, krea2_reference_edit_acc=krea2_reference_edit_accordion, qwen_image_edit_acc=qwen_image_edit_accordion, ref_img_acc=ref_img_accordion, sensenova_ref_acc=sensenova_ref_accordion,
198
+ task_type=task_type, type_comp=type_comp, qwen_pe_acc=qwen_pe_accordion
199
  )
200
  if type_comp:
201
  inputs2.append(type_comp)
 
289
  f'krea2_reference_edit_accordion_{prefix}': 'krea2_style_reference',
290
  f'qwen_image_edit_accordion_{prefix}': 'qwen_image_edit',
291
  f'reference_image_accordion_{prefix}': 'reference_image',
292
+ f'qwen_image_2_1_prompt_enhancer_accordion_{prefix}': 'qwen_image_2_1_prompt_enhancer',
293
  f'pid_accordion_{prefix}': 'pid',
294
  f'vae_accordion_{prefix}': 'vae',
295
  }
 
327
  'hidream_o1_reference_accordion_imagegen', 'sensenova_reference_accordion_imagegen', 'joyai_reference_accordion_imagegen',
328
  'krea2_identity_edit_accordion_imagegen', 'krea2_reference_edit_accordion_imagegen',
329
  'qwen_image_edit_accordion_imagegen',
330
+ 'reference_image_accordion_imagegen',
331
+ 'qwen_image_2_1_prompt_enhancer_accordion_imagegen',
332
+ 'pid_accordion_imagegen', 'vae_accordion_imagegen',
333
  ]
334
  for key in accordion_keys:
335
  if key in ui_components:
ui/events/run_handlers.py CHANGED
@@ -37,6 +37,13 @@ def create_run_event(prefix: str, task_type: str = None, ui_components: dict = N
37
  if ui_components.get(f'pid_settings_{prefix}'):
38
  run_inputs_map['pid_settings'] = ui_components[f'pid_settings_{prefix}']
39
 
 
 
 
 
 
 
 
40
  # Generic / Txt2Img inputs
41
  if ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'):
42
  run_inputs_map['width'] = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
 
37
  if ui_components.get(f'pid_settings_{prefix}'):
38
  run_inputs_map['pid_settings'] = ui_components[f'pid_settings_{prefix}']
39
 
40
+ if ui_components.get(f'qwen_image_2_1_prompt_enhancer_enable_{prefix}'):
41
+ run_inputs_map['qwen_image_2_1_prompt_enhancer_enable'] = ui_components[f'qwen_image_2_1_prompt_enhancer_enable_{prefix}']
42
+ if ui_components.get(f'qwen_image_2_1_prompt_enhancer_thinking_{prefix}'):
43
+ run_inputs_map['qwen_image_2_1_prompt_enhancer_thinking'] = ui_components[f'qwen_image_2_1_prompt_enhancer_thinking_{prefix}']
44
+ if ui_components.get(f'qwen_image_2_1_prompt_enhancer_max_length_{prefix}'):
45
+ run_inputs_map['qwen_image_2_1_prompt_enhancer_max_length'] = ui_components[f'qwen_image_2_1_prompt_enhancer_max_length_{prefix}']
46
+
47
  # Generic / Txt2Img inputs
48
  if ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width'):
49
  run_inputs_map['width'] = ui_components.get(f'width_{prefix}') or ui_components.get(f'{prefix}_width')
ui/imagegen_ui.py CHANGED
@@ -9,7 +9,7 @@ from .shared.ui_components import (
9
  create_model_architecture_filter_ui, create_category_filter_ui,
10
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
11
  create_reference_latent_ui, create_hidream_o1_reference_ui, create_sensenova_reference_ui, create_joyai_reference_ui, create_reference_image_ui, create_krea2_identity_edit_ui, create_krea2_reference_edit_ui, create_qwen_image_edit_ui,
12
- create_pid_ui
13
  )
14
 
15
  default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
@@ -190,6 +190,7 @@ def create_ui():
190
  components.update(create_krea2_reference_edit_ui(prefix))
191
  components.update(create_qwen_image_edit_ui(prefix))
192
  components.update(create_reference_image_ui(prefix))
 
193
  components.update(create_vae_override_ui(prefix))
194
  components.update(create_pid_ui(prefix))
195
  components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
 
9
  create_model_architecture_filter_ui, create_category_filter_ui,
10
  create_sd3_ipadapter_ui, create_flux1_ipadapter_ui, create_style_ui,
11
  create_reference_latent_ui, create_hidream_o1_reference_ui, create_sensenova_reference_ui, create_joyai_reference_ui, create_reference_image_ui, create_krea2_identity_edit_ui, create_krea2_reference_edit_ui, create_qwen_image_edit_ui,
12
+ create_pid_ui, create_qwen_image_2_1_prompt_enhancer_ui
13
  )
14
 
15
  default_vals = MODEL_DEFAULTS_CONFIG.get('Default', {})
 
190
  components.update(create_krea2_reference_edit_ui(prefix))
191
  components.update(create_qwen_image_edit_ui(prefix))
192
  components.update(create_reference_image_ui(prefix))
193
+ components.update(create_qwen_image_2_1_prompt_enhancer_ui(prefix))
194
  components.update(create_vae_override_ui(prefix))
195
  components.update(create_pid_ui(prefix))
196
  components[f'accordion_wrapper_{prefix}'] = accordion_wrapper
ui/shared/ui_components.py CHANGED
@@ -882,4 +882,37 @@ def create_krea2_reference_edit_ui(prefix: str, max_units=3):
882
 
883
  components[key('all_krea2_reference_edit_components_flat')] = ref_image_inputs
884
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
885
  return components
 
882
 
883
  components[key('all_krea2_reference_edit_components_flat')] = ref_image_inputs
884
 
885
+ return components
886
+
887
+
888
+ def create_qwen_image_2_1_prompt_enhancer_ui(prefix: str):
889
+ components = {}
890
+ key = lambda name: f"{name}_{prefix}"
891
+
892
+ with gr.Accordion("Qwen-Image-2.1 Prompt Enhancer Settings", open=False, visible=('qwen_image_2_1_prompt_enhancer' in default_enabled_chains)) as enhancer_accordion:
893
+ components[key('qwen_image_2_1_prompt_enhancer_accordion')] = enhancer_accordion
894
+ gr.Markdown("💡 **Tip:** Automatically selects between [Qwen-Image-2.1-PE-T2I](https://huggingface.co/Qwen/Qwen-Image-2.1-PE-T2I) and [Qwen-Image-2.1-PE-I2I](https://huggingface.co/Qwen/Qwen-Image-2.1-PE-I2I) for prompt enhancement based on input context.")
895
+ with gr.Row():
896
+ components[key('qwen_image_2_1_prompt_enhancer_enable')] = gr.Checkbox(
897
+ label="Enable Qwen-Image-2.1 Prompt Enhancer",
898
+ value=False,
899
+ interactive=True,
900
+ scale=2
901
+ )
902
+ components[key('qwen_image_2_1_prompt_enhancer_thinking')] = gr.Checkbox(
903
+ label="Enable Thinking (Reasoning CoT)",
904
+ value=False,
905
+ interactive=True,
906
+ scale=2
907
+ )
908
+ components[key('qwen_image_2_1_prompt_enhancer_max_length')] = gr.Number(
909
+ label="Max Length",
910
+ value=512,
911
+ precision=0,
912
+ minimum=16,
913
+ step=16,
914
+ interactive=True,
915
+ scale=1
916
+ )
917
+
918
  return components
yaml/chain_features.yaml CHANGED
@@ -525,3 +525,25 @@ embedding:
525
  required:
526
  - source
527
  - embedding_value
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  required:
526
  - source
527
  - embedding_value
528
+
529
+ qwen_image_2_1_prompt_enhancer:
530
+ chains: qwen_image_2_1_prompt_enhancer
531
+ display_name: "Qwen-Image-2.1 Prompt Enhancer Settings"
532
+ description: "Enhance prompts using Qwen-Image-2.1 Prompt Enhancer with automatic model selection (T2I vs I2I/reference images) and optional reasoning CoT thinking mode."
533
+ max_count: 1
534
+ usage_guideline: "Set enable to true to activate prompt enhancement. Enable thinking to allow reasoning CoT (reasoning tags are automatically stripped from the resulting prompt). Set max_length to control generation length."
535
+ parameters_schema:
536
+ type: object
537
+ properties:
538
+ enable:
539
+ type: boolean
540
+ default: false
541
+ description: "Enable Qwen-Image-2.1 Prompt Enhancer."
542
+ thinking:
543
+ type: boolean
544
+ default: false
545
+ description: "Enable thinking (reasoning CoT). Thought text inside <think> tags will be automatically stripped before passing prompt to downstream text encoding."
546
+ max_length:
547
+ type: integer
548
+ default: 512
549
+ description: "Maximum generation length for prompt enhancement."
yaml/file_list.yaml CHANGED
@@ -911,6 +911,15 @@ file:
911
  source: "hf"
912
  repo_id: "Comfy-Org/Ideogram-4"
913
  repository_file_path: "text_encoders/qwen3vl_8b_nvfp4.safetensors"
 
 
 
 
 
 
 
 
 
914
  # PixelDiT
915
  - filename: "gemma_2_2b_it_elm_fp8_scaled.safetensors"
916
  source: "hf"
@@ -1006,10 +1015,6 @@ file:
1006
  source: "hf"
1007
  repo_id: "Comfy-Org/Omnigen2_ComfyUI_repackaged"
1008
  repository_file_path: "split_files/text_encoders/qwen_2.5_vl_fp16.safetensors"
1009
- - filename: "qwen3vl_8b_w4a8.safetensors"
1010
- source: "hf"
1011
- repo_id: "Comfy-Org/Qwen-Image-2.1"
1012
- repository_file_path: "text_encoders/qwen3vl_8b_w4a8.safetensors"
1013
  vae:
1014
  - filename: "wan_2.1_vae.safetensors"
1015
  source: "hf"
 
911
  source: "hf"
912
  repo_id: "Comfy-Org/Ideogram-4"
913
  repository_file_path: "text_encoders/qwen3vl_8b_nvfp4.safetensors"
914
+ # Qwen-Image-2.1 Prompt Enhancers
915
+ - filename: "qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors"
916
+ source: "hf"
917
+ repo_id: "Comfy-Org/Qwen-Image-2.1"
918
+ repository_file_path: "text_encoders/qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors"
919
+ - filename: "qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors"
920
+ source: "hf"
921
+ repo_id: "Comfy-Org/Qwen-Image-2.1"
922
+ repository_file_path: "text_encoders/qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors"
923
  # PixelDiT
924
  - filename: "gemma_2_2b_it_elm_fp8_scaled.safetensors"
925
  source: "hf"
 
1015
  source: "hf"
1016
  repo_id: "Comfy-Org/Omnigen2_ComfyUI_repackaged"
1017
  repository_file_path: "split_files/text_encoders/qwen_2.5_vl_fp16.safetensors"
 
 
 
 
1018
  vae:
1019
  - filename: "wan_2.1_vae.safetensors"
1020
  source: "hf"
yaml/model_architecture_features.yaml CHANGED
@@ -74,6 +74,7 @@ qwen-image-2.1:
74
  enabled_chains:
75
  - lora
76
  - reference_image
 
77
 
78
  qwen-image:
79
  enabled_chains:
 
74
  enabled_chains:
75
  - lora
76
  - reference_image
77
+ - qwen_image_2_1_prompt_enhancer
78
 
79
  qwen-image:
80
  enabled_chains:
yaml/model_list.yaml CHANGED
@@ -19,7 +19,7 @@ Checkpoint:
19
  components:
20
  unet: "qwen_image_2.1_int8_convrot.safetensors"
21
  vae: "qwen_image_2.1_vae_bf16.safetensors"
22
- clip: "qwen3vl_8b_w4a8.safetensors"
23
  SenseNova-U1.5:
24
  latent_type: hidream_o1_latent
25
  models:
@@ -319,7 +319,7 @@ Checkpoint:
319
  unet: "novaAnimeAM_v40.safetensors"
320
  vae: "qwen_image_vae.safetensors"
321
  clip: "qwen_3_06b_base.safetensors"
322
- - display_name: "RAMTHRUST/RAMTHRUST'S-NSFW-PINK-ALCHEMY-ANIMA-v3.1"
323
  components:
324
  unet: "ramthrustsNSFWPINK_v31RAMSDelicious.safetensors"
325
  vae: "qwen_image_vae.safetensors"
 
19
  components:
20
  unet: "qwen_image_2.1_int8_convrot.safetensors"
21
  vae: "qwen_image_2.1_vae_bf16.safetensors"
22
+ clip: "qwen3vl_8b_nvfp4.safetensors"
23
  SenseNova-U1.5:
24
  latent_type: hidream_o1_latent
25
  models:
 
319
  unet: "novaAnimeAM_v40.safetensors"
320
  vae: "qwen_image_vae.safetensors"
321
  clip: "qwen_3_06b_base.safetensors"
322
+ - display_name: "Crody/RAMTHRUST'S-NSFW-PINK-ALCHEMY-ANIMA-v3.1"
323
  components:
324
  unet: "ramthrustsNSFWPINK_v31RAMSDelicious.safetensors"
325
  vae: "qwen_image_vae.safetensors"
yaml/task_features.yaml CHANGED
@@ -25,6 +25,7 @@ txt2img:
25
  - krea2_style_reference
26
  - qwen_image_edit
27
  - reference_image
 
28
  - pid
29
  - vae
30
 
@@ -50,6 +51,7 @@ img2img:
50
  - krea2_style_reference
51
  - qwen_image_edit
52
  - reference_image
 
53
  - vae
54
 
55
  inpaint:
@@ -74,6 +76,7 @@ inpaint:
74
  - krea2_style_reference
75
  - qwen_image_edit
76
  - reference_image
 
77
  - vae
78
 
79
  outpaint:
@@ -98,6 +101,7 @@ outpaint:
98
  - krea2_style_reference
99
  - qwen_image_edit
100
  - reference_image
 
101
  - vae
102
 
103
  hires_fix:
@@ -122,4 +126,5 @@ hires_fix:
122
  - krea2_style_reference
123
  - qwen_image_edit
124
  - reference_image
 
125
  - vae
 
25
  - krea2_style_reference
26
  - qwen_image_edit
27
  - reference_image
28
+ - qwen_image_2_1_prompt_enhancer
29
  - pid
30
  - vae
31
 
 
51
  - krea2_style_reference
52
  - qwen_image_edit
53
  - reference_image
54
+ - qwen_image_2_1_prompt_enhancer
55
  - vae
56
 
57
  inpaint:
 
76
  - krea2_style_reference
77
  - qwen_image_edit
78
  - reference_image
79
+ - qwen_image_2_1_prompt_enhancer
80
  - vae
81
 
82
  outpaint:
 
101
  - krea2_style_reference
102
  - qwen_image_edit
103
  - reference_image
104
+ - qwen_image_2_1_prompt_enhancer
105
  - vae
106
 
107
  hires_fix:
 
126
  - krea2_style_reference
127
  - qwen_image_edit
128
  - reference_image
129
+ - qwen_image_2_1_prompt_enhancer
130
  - vae