refactor: simplify Qwen-Image-2.1 prompt enhancer and update dependencies
Browse filesFiles changed (2)
8 unmodified lines910111213141516221 unmodified lines2382392402412422432442452462472482492502512522532542552562572582598 unmodified lines- I2I / Reference: qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors- Handles single or multi-reference inputs: multiple reference images are stitched intoa structured grid layout via ComfyUI native ImageStitch nodes and scaled via ImageScaleToTotalPixels.- Supports reasoning mode (thinking=True) with automatic reasoning tag stripping via RegexReplace(^.*?</think>\\s*) to prevent thought chain text from contaminating downstream image conditioning."""try:221 unmodified linestext_gen_node['inputs'] = text_gen_inputsassembler.workflow[text_gen_node_id] = text_gen_node# 4. Insert Replace Text (Regex) node if thinking is enabled to strip reasoning tagsif thinking_enabled:regex_node_id = assembler._get_unique_id()regex_node = create_node(assembler, "RegexReplace", "Replace Text (Regex)")regex_node['inputs'] = {"string": [text_gen_node_id, 0],"regex_pattern": "^.*?</think>\\s*","replace": "","case_insensitive": True,"multiline": False,"dotall": True,"count": 0}assembler.workflow[regex_node_id] = regex_nodetarget_node['inputs']['prompt'] = [regex_node_id, 0]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).")else:target_node['inputs']['prompt'] = [text_gen_node_id, 0]print(f"[Injector] Qwen-Image-2.1 Prompt Enhancer applied successfully ({'I2I' if has_load_image else 'T2I'}, clip='{clip_model_name}', thinking=False).")8 unmodified lines910111213141516221 unmodified lines2382392402412422432442458 unmodified lines- I2I / Reference: qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors- Handles single or multi-reference inputs: multiple reference images are stitched intoa structured grid layout via ComfyUI native ImageStitch nodes and scaled via ImageScaleToTotalPixels.- Supports reasoning mode (thinking=True) leveraging ComfyUI TextGenerate native reasoning separation(output slot 0 outputs clean prompt text, while output slot 1 isolates reasoning chain)."""try:221 unmodified linestext_gen_node['inputs'] = text_gen_inputsassembler.workflow[text_gen_node_id] = text_gen_node# 4. Connect TextGenerate output directly to target node prompt# ComfyUI TextGenerate node natively strips reasoning tags (<think>...</think>) into output slot 1,# leaving clean enhanced prompt in output slot 0.target_node['inputs']['prompt'] = [text_gen_node_id, 0]print(f"[Injector] Qwen-Image-2.1 Prompt Enhancer applied successfully ({'I2I' if has_load_image else 'T2I'}, clip='{clip_model_name}', thinking={thinking_enabled}).")
12345678910comfyui-frontend-package==1.53.6comfyui-workflow-templates==0.11.66comfyui-embedded-docs==0.5.12torchtorchsdetorchvisiontorchaudionumpy>=1.25.0einopstransformers>=4.50.3123456789comfyui-frontend-package==1.53.6comfyui-workflow-templates==0.11.68comfyui-embedded-docs==0.5.12torchtorchsdetorchvisionnumpy>=1.25.0einopstransformers>=4.50.3
chain_injectors/qwen_image_2_1_prompt_enhancer_injector.py+7-21
requirements.txt+1-2