Transform your 3D texturing workflow with the power of generative AI, directly within Blender!
feat: flux.2 klein 4b/9b architecture (initial support)
sakalondf946fc97330e
diff --git a/installer.py b/installer.pyindex 909b8c5..4604106 100644--- a/installer.py+++ b/installer.py@@ -604,6 +604,31 @@ DEPENDENCIES: Dict[str, Dict[str, Any]] = {"license": "Apache 2.0", "packages": ["vlm_emission"],"pip_packages": ["segment_anything"],},+ # --- FLUX.2 Klein 4B ---+ "model_flux2_klein_4b": {+ "id": "model_flux2_klein_4b", "type": "model",+ "name": "FLUX.2 Klein 4B Diffusion Model (FP8)",+ "url": "https://huggingface.co/black-forest-labs/FLUX.2-klein-base-4b-fp8/resolve/main/flux-2-klein-base-4b-fp8.safetensors?download=true",+ "target_path_relative": "models/diffusion_models",+ "filename": "flux-2-klein-base-4b-fp8.safetensors",+ "license": "Apache 2.0", "size_mb": 4070, "packages": ["flux2_klein"],+ },+ "model_flux2_text_encoder": {+ "id": "model_flux2_text_encoder", "type": "model",+ "name": "FLUX.2 Klein Qwen 3 4B Text Encoder (bf16)",+ "url": "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/text_encoders/qwen_3_4b.safetensors?download=true",+ "target_path_relative": "models/text_encoders",+ "filename": "qwen_3_4b.safetensors",+ "license": "Apache 2.0", "size_mb": 8050, "packages": ["flux2_klein"],+ },+ "model_flux2_vae": {+ "id": "model_flux2_vae", "type": "model",+ "name": "FLUX.2 Klein VAE",+ "url": "https://huggingface.co/Comfy-Org/flux2-dev/resolve/main/split_files/vae/flux2-vae.safetensors?download=true",+ "target_path_relative": "models/vae",+ "filename": "flux2-vae.safetensors",+ "license": "Apache 2.0", "size_mb": 321, "packages": ["flux2_klein"],+ },}# Define what items each menu option entails by listing package tags@@ -663,6 +688,13 @@ MENU_PACKAGES: Dict[str, Dict[str, Any]] = {" *GroundingDINO_SwinB (~938MB) and sam_vit_h (~2.56GB) models are downloaded*\n"" *automatically on first use.*",},+ '12': {"name": "[FLUX.2 KLEIN] Klein 4B FP8 + Qwen 3 Text Encoder + VAE",+ "tags": ["flux2_klein"],+ "size_gb": 12.4,+ "description_suffix": "*Downloads FLUX.2 Klein 4B FP8 diffusion model (~4.1GB), Qwen 3 4B text encoder bf16 (~8.0GB),*\n"+ " *and FLUX.2 VAE (~0.3GB). All ComfyUI nodes are built-in (no custom nodes needed).*\n"+ " *Apache 2.0 license. Requires ~13GB VRAM.*",+ },}# --- Helper Functions ---@@ -1067,7 +1099,7 @@ def main():while True:display_menu(comfyui_base_path)- choice = input("Enter your choice (1-11, or q to quit): ").strip().lower()+ choice = input("Enter your choice (1-12, or q to quit): ").strip().lower()if choice == 'q':print("Exiting installer.")diff --git a/stablegen/__init__.py b/stablegen/__init__.pyindex 8fedc19..3ed24b2 100644--- a/stablegen/__init__.py+++ b/stablegen/__init__.py@@ -150,7 +150,7 @@ def _sync_trellis2_backbone(scene):and texture_mode is native/none)."""tex_mode = getattr(scene, 'trellis2_texture_mode', 'native')- if tex_mode in ('sdxl', 'flux1', 'qwen_image_edit'):+ if tex_mode in ('sdxl', 'flux1', 'qwen_image_edit', 'flux2_klein'):target = tex_modeelif getattr(scene, 'trellis2_generate_from', 'image') == 'prompt':target = getattr(scene, 'trellis2_initial_image_arch', 'sdxl')@@ -1112,6 +1112,9 @@ class RefreshCheckpointList(bpy.types.Operator):if extra:model_list.extend(extra)model_type_desc = "UNET" if architecture == 'flux1' else "UNET (GGUF/Safetensors)"+ elif architecture == 'flux2_klein':+ model_list = _fetch_api_list(server_address, "/models/diffusion_models")+ model_type_desc = "Diffusion Model"else:model_type_desc = "Model"return {'model_list': model_list, 'architecture': architecture,@@ -2327,7 +2330,8 @@ def register():items=[('sdxl', 'SDXL', ''),('flux1', 'Flux 1', ''),- ('qwen_image_edit', 'Qwen Image Edit', '')+ ('qwen_image_edit', 'Qwen Image Edit', ''),+ ('flux2_klein', 'FLUX.2 Klein', '')],default='sdxl',update=update_combined@@ -2340,6 +2344,7 @@ def register():('sdxl', 'SDXL', 'Stable Diffusion XL'),('flux1', 'Flux 1', 'Flux 1 architecture'),('qwen_image_edit', 'Qwen Image Edit', 'Qwen Image Edit architecture'),+ ('flux2_klein', 'FLUX.2 Klein', 'FLUX.2 Klein multi-reference edit model (Apache 2.0)'),('trellis2', 'TRELLIS.2', 'Image to 3D mesh generation with TRELLIS.2'),],default='sdxl',@@ -2366,6 +2371,7 @@ def register():('sdxl', 'SDXL', 'Use SDXL for camera-based texture projection'),('flux1', 'Flux 1', 'Use Flux 1 for camera-based texture projection'),('qwen_image_edit', 'Qwen Image Edit', 'Use Qwen for camera-based texture projection'),+ ('flux2_klein', 'FLUX.2 Klein', 'Use FLUX.2 Klein for camera-based texture projection'),],default='native',update=update_trellis2_texture_mode@@ -2378,6 +2384,7 @@ def register():('sdxl', 'SDXL', 'Stable Diffusion XL'),('flux1', 'Flux 1', 'Flux 1 architecture'),('qwen_image_edit', 'Qwen Image Edit', 'Qwen Image Edit architecture'),+ ('flux2_klein', 'FLUX.2 Klein', 'FLUX.2 Klein multi-reference edit'),],default='sdxl',update=update_trellis2_initial_image_archdiff --git a/stablegen/generator.py b/stablegen/generator.pyindex 11cfce7..8695cb8 100644--- a/stablegen/generator.py+++ b/stablegen/generator.py@@ -629,8 +629,8 @@ class ComfyUIGenerate(bpy.types.Operator):print("Executing ComfyUI Generation")- if context.scene.model_architecture == 'qwen_image_edit' and not context.scene.generation_mode == 'project_only':- context.scene.generation_method = 'sequential' # Force sequential for Qwen Image Edit+ if context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein') and not context.scene.generation_mode == 'project_only':+ context.scene.generation_method = 'sequential' # Force sequential for edit modelsrender = bpy.context.scene.renderresolution_x = render.resolution_x@@ -640,11 +640,17 @@ class ComfyUIGenerate(bpy.types.Operator):# Qwen Image Edit benefits from 112-aligned resolution (LCM of VAE=8,# ViT patch=14, spatial merge=2×14=28, ViT window=112) to avoid# subtle pixel shifts between the latent, VAE and CLIP grids.+ # FLUX.2 Klein uses 16x latent downscale, so 16-aligned is needed.use_qwen_alignment = (context.scene.model_architecture.startswith('qwen')and getattr(context.scene, 'qwen_rescale_alignment', False))- align_step = 112 if use_qwen_alignment else 8+ if use_qwen_alignment:+ align_step = 112+ elif context.scene.model_architecture == 'flux2_klein':+ align_step = 16+ else:+ align_step = 8target_px = int(getattr(context.scene, 'auto_rescale_target_mp', 1.0) * 1_000_000)upper_bound = int(target_px * 1.2)@@ -710,7 +716,7 @@ class ComfyUIGenerate(bpy.types.Operator):# Check if there is at least one ControlNet unitcontrolnet_units = getattr(context.scene, "controlnet_units", [])- if not controlnet_units and not (context.scene.use_flux_lora and context.scene.model_architecture == 'flux1'):+ if not controlnet_units and not (context.scene.use_flux_lora and context.scene.model_architecture == 'flux1') and context.scene.model_architecture != 'flux2_klein':self.report({'ERROR'}, "At least one ControlNet unit is required to run the operator.")context.scene.generation_status = 'idle'ComfyUIGenerate._is_running = False@@ -939,7 +945,7 @@ class ComfyUIGenerate(bpy.types.Operator):# Reset discard factor if enabledif (context.scene.discard_factor_generation_only and- (self._generation_method_on_start == 'sequential' or context.scene.model_architecture == 'qwen_image_edit')):+ (self._generation_method_on_start == 'sequential' or context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein'))):new_discard_angle = context.scene.discard_factor_after_generationprint(f"Resetting discard angle in material nodes to {new_discard_angle}...")@@ -962,7 +968,7 @@ class ComfyUIGenerate(bpy.types.Operator):# Reset weight exponent if enabledif (context.scene.weight_exponent_generation_only and- (self._generation_method_on_start == 'sequential' or context.scene.model_architecture == 'qwen_image_edit')):+ (self._generation_method_on_start == 'sequential' or context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein'))):new_exponent = context.scene.weight_exponent_after_generationprint(f"Resetting weight exponent in material nodes to {new_exponent}...")@@ -1068,7 +1074,7 @@ class ComfyUIGenerate(bpy.types.Operator):need_depth = (any(u["unit_type"] == "depth" for u in controlnet_units)or (context.scene.use_flux_lora and context.scene.model_architecture == 'flux1')- or (context.scene.model_architecture == 'qwen_image_edit'+ or (context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein')and context.scene.qwen_guidance_map_type == 'depth')or (context.scene.model_architecture.startswith('qwen')and context.scene.qwen_generation_method in ('refine', 'local_edit')@@ -1113,7 +1119,7 @@ class ComfyUIGenerate(bpy.types.Operator):need_normal = (any(u["unit_type"] == "normal" for u in controlnet_units)- or (context.scene.model_architecture == 'qwen_image_edit'+ or (context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein')and context.scene.qwen_guidance_map_type == 'normal'))if need_normal and context.scene.generation_method != 'uv_inpaint':@@ -1134,7 +1140,7 @@ class ComfyUIGenerate(bpy.types.Operator):return# Qwen guidance using Workbench- if (context.scene.model_architecture == 'qwen_image_edit'+ if (context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein')and context.scene.qwen_guidance_map_type == 'workbench'and context.scene.generation_method != 'uv_inpaint'):workbench_dir = get_dir_path(context, "controlnet")["workbench"]@@ -1156,7 +1162,7 @@ class ComfyUIGenerate(bpy.types.Operator):return# Qwen guidance using Viewport- elif (context.scene.model_architecture == 'qwen_image_edit'+ elif (context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein')and context.scene.qwen_guidance_map_type == 'viewport'and context.scene.generation_method != 'uv_inpaint'):viewport_dir = get_dir_path(context, "controlnet")["viewport"]@@ -1348,6 +1354,8 @@ class ComfyUIGenerate(bpy.types.Operator):image = self.workflow_manager.generate_flux(context, controlnet_info=controlnet_info, ipadapter_ref_info=ipadapter_ref_info)elif context.scene.model_architecture == 'qwen_image_edit':image = self.workflow_manager.generate_qwen_edit(context, camera_id=camera_id)+ elif context.scene.model_architecture == 'flux2_klein':+ image = self.workflow_manager.generate_flux2_klein(context, camera_id=camera_id)else:image = self.workflow_manager.generate(context, controlnet_info=controlnet_info, ipadapter_ref_info=ipadapter_ref_info)else:@@ -1365,7 +1373,7 @@ class ComfyUIGenerate(bpy.types.Operator):export_visibility(context, self._to_texture, camera_visibility=_vis_cam) # Export mask for current view_emit_cam = _cur_camwith _SGCameraResolution(context, _emit_cam):- if context.scene.model_architecture == 'qwen_image_edit': # export custom bg and fallback for Qwen image edit+ if context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein'): # export custom bg and fallback for Qwen/Klein image editfallback_color, background_color = self._get_qwen_context_colors(context)export_emit_image(context, self._to_texture, camera_id=self._current_image, bg_color=background_color, fallback_color=fallback_color) # Export render for next viewself._dilate_qwen_context_fallback(context, self._current_image, fallback_color)@@ -1390,6 +1398,8 @@ class ComfyUIGenerate(bpy.types.Operator):image = self.workflow_manager.refine_flux(context, controlnet_info=controlnet_info, render_info=render_info, mask_info=mask_info, ipadapter_ref_info=ipadapter_ref_info)elif context.scene.model_architecture == 'qwen_image_edit':image = self.workflow_manager.generate_qwen_edit(context, camera_id=camera_id)+ elif context.scene.model_architecture == 'flux2_klein':+ image = self.workflow_manager.generate_flux2_klein(context, camera_id=camera_id)else:image = self.workflow_manager.refine(context, controlnet_info=controlnet_info, render_info=render_info, mask_info=mask_info, ipadapter_ref_info=ipadapter_ref_info)else: # Grid or Separate@@ -1397,13 +1407,15 @@ class ComfyUIGenerate(bpy.types.Operator):image = self.workflow_manager.generate_flux(context, controlnet_info=controlnet_info, ipadapter_ref_info=ipadapter_ref_info)elif context.scene.model_architecture == 'qwen_image_edit':image = self.workflow_manager.generate_qwen_edit(context, camera_id=camera_id)+ elif context.scene.model_architecture == 'flux2_klein':+ image = self.workflow_manager.generate_flux2_klein(context, camera_id=camera_id)else:image = self.workflow_manager.generate(context, controlnet_info=controlnet_info, ipadapter_ref_info=ipadapter_ref_info)if image == {"error": "conn_failed"}:return # Error message already set- if (context.scene.model_architecture == 'qwen_image_edit' and+ if (context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein') andcontext.scene.generation_method == 'sequential' andself._current_image > 0 andcontext.scene.qwen_context_cleanup and@@ -3198,7 +3210,7 @@ class ComfyUIGenerate(bpy.types.Operator):is_recent_mode_ref = (file_type == "generated" andcontext.scene.sequential_ipadapter_mode == 'recent' and- (context.scene.sequential_ipadapter or context.scene.model_architecture == 'qwen_image_edit')+ (context.scene.sequential_ipadapter or context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein')))temp_image_path = Nonediff --git a/stablegen/project.py b/stablegen/project.pyindex b4ce530..d5a660f 100644--- a/stablegen/project.py+++ b/stablegen/project.py@@ -1484,7 +1484,7 @@ def project_image(context, to_project, mat_id, stop_index=1000000):return to_float# Voronoi mode flag: keep natural weights for non-generated cameras- voronoi_active = (context.scene.model_architecture == 'qwen_image_edit'+ voronoi_active = (context.scene.model_architecture in ('qwen_image_edit', 'flux2_klein')and getattr(context.scene, 'qwen_voronoi_mode', False)and context.scene.generation_method == 'sequential')diff --git a/stablegen/render_tools.py b/stablegen/render_tools.pyindex 1a39ad1..b0fd8cc 100644--- a/stablegen/render_tools.py+++ b/stablegen/render_tools.py@@ -690,7 +690,7 @@ def export_emit_image(context, to_export, camera_id=None, bg_color=(0.5, 0.5, 0.links.new(color_mix.outputs[0], output.inputs[0])output_dir = get_dir_path(context, "inpaint")["visibility"] if "visibility" in str(camera_id) else get_dir_path(context, "inpaint")["render"]- output_file = f"render{camera_id}" if camera_id is not None else "render"+ output_file = f"ctx_render{camera_id}" if camera_id is not None else "ctx_render"# Store and set world settingsworld = context.scene.worlddiff --git a/stablegen/stablegen.py b/stablegen/stablegen.pyindex d51e3b2..888057f 100644--- a/stablegen/stablegen.py+++ b/stablegen/stablegen.py@@ -29,6 +29,10 @@ PRESETS = {"QWEN SAFE (NUNCHAKU)": {"description": "Safer fallback using Nunchaku. Meant to be used with the Nunchaku model which has the 4-step Lightning LoRA included. Requires Nunchaku nodes.", "control_after_generate": "fixed", "model_architecture": "qwen_image_edit", "qwen_generation_method": "generate", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 6.0, "weight_exponent_generation_only": False, "weight_exponent_after_generation": 15.0, "qwen_voronoi_mode": False, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 0.8, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.10000000149011612, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "early_priority": False, "early_priority_strength": 0.5, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "NONE", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Change the format of image 1 to '{main_prompt}'", "qwen_custom_prompt_seq_none": "Change and transfer the format of '{main_prompt}' in image 1 to the style from image 2", "qwen_custom_prompt_seq_replace": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas.", "qwen_custom_prompt_seq_additional": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas. Image 3 represents the overall style of the object.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": True, "lora_units": []},"QWEN ALT (NUNCHAKU)": {"description": "Balanced option using Nunchaku. Meant to be used with the Nunchaku model which has the 4-step Lightning LoRA included. Requires Nunchaku nodes.", "control_after_generate": "fixed", "model_architecture": "qwen_image_edit", "qwen_generation_method": "generate", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 3.0, "weight_exponent_generation_only": False, "weight_exponent_after_generation": 15.0, "qwen_voronoi_mode": False, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 0.8, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "recent", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.10000000149011612, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "ADDITIONAL", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Change the format of image 1 to '{main_prompt}'", "qwen_custom_prompt_seq_none": "Change and transfer the format of '{main_prompt}' in image 1 to the style from image 2", "qwen_custom_prompt_seq_replace": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas.", "qwen_custom_prompt_seq_additional": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas. Image 3 represents the overall style of the object.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": True, "early_priority": True, "early_priority_strength": 0.5, "lora_units": []},"QWEN VORONOI (NUNCHAKU)": {"description": "Voronoi projection mode using Nunchaku. Exponent 1000 for hard camera segmentation during generation, then resets to 15 for softer blending. Requires Nunchaku nodes.", "control_after_generate": "fixed", "model_architecture": "qwen_image_edit", "qwen_generation_method": "generate", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 1000.0, "weight_exponent_generation_only": True, "weight_exponent_after_generation": 15.0, "qwen_voronoi_mode": True, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 0.8, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.0, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "REPLACE_STYLE", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Change the format of image 1 to '{main_prompt}'", "qwen_custom_prompt_seq_none": "Change and transfer the format of '{main_prompt}' in image 1 to the style from image 2", "qwen_custom_prompt_seq_replace": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas.", "qwen_custom_prompt_seq_additional": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas. Image 3 represents the overall style of the object.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": True, "lora_units": []},+ "KLEIN PRECISE": {"description": "FLUX.2 Klein with precise detail when camera overlap is good. Uses depth reference images with CFGGuider (cfg=1). Best for well-covered geometry.", "control_after_generate": "fixed", "model_architecture": "flux2_klein", "qwen_generation_method": "generate", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 3.0, "weight_exponent_generation_only": False, "weight_exponent_after_generation": 15.0, "qwen_voronoi_mode": False, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 0.8, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.0, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "REPLACE_STYLE", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour.", "qwen_custom_prompt_seq_none": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour, adopting the visual style from image 2.", "qwen_custom_prompt_seq_replace": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray.", "qwen_custom_prompt_seq_additional": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray. Image 3 represents the overall style.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": True, "lora_units": []},+ "KLEIN SAFE": {"description": "FLUX.2 Klein safer fallback when coverage is limited. Uses the previous view instead of context renders with depth references and CFGGuider (cfg=1).", "control_after_generate": "fixed", "model_architecture": "flux2_klein", "qwen_generation_method": "generate", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 6.0, "weight_exponent_generation_only": False, "weight_exponent_after_generation": 15.0, "qwen_voronoi_mode": False, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 0.8, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "first", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.10000000149011612, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "early_priority": False, "early_priority_strength": 0.5, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "NONE", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour.", "qwen_custom_prompt_seq_none": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour, adopting the visual style from image 2.", "qwen_custom_prompt_seq_replace": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray.", "qwen_custom_prompt_seq_additional": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray. Image 3 represents the overall style.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": True, "lora_units": []},+ "KLEIN ALT": {"description": "FLUX.2 Klein balanced option that mixes additional context renders with sequential references. Uses depth references and CFGGuider (cfg=1).", "control_after_generate": "fixed", "model_architecture": "flux2_klein", "qwen_generation_method": "generate", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 3.0, "weight_exponent_generation_only": False, "weight_exponent_after_generation": 15.0, "qwen_voronoi_mode": False, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 0.8, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "recent", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.10000000149011612, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "ADDITIONAL", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour.", "qwen_custom_prompt_seq_none": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour, adopting the visual style from image 2.", "qwen_custom_prompt_seq_replace": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray.", "qwen_custom_prompt_seq_additional": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray. Image 3 represents the overall style.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": True, "early_priority": True, "early_priority_strength": 0.5, "lora_units": []},+ "KLEIN VORONOI": {"description": "FLUX.2 Klein voronoi projection mode. Exponent 1000 for hard camera segmentation during generation, then resets to 15 for softer blending. Uses depth references and CFGGuider (cfg=1).", "control_after_generate": "fixed", "model_architecture": "flux2_klein", "qwen_generation_method": "generate", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 1000.0, "weight_exponent_generation_only": True, "weight_exponent_after_generation": 15.0, "qwen_voronoi_mode": True, "clip_skip": 1, "auto_rescale": True, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 0.8, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.0, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "REPLACE_STYLE", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour.", "qwen_custom_prompt_seq_none": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour, adopting the visual style from image 2.", "qwen_custom_prompt_seq_replace": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray.", "qwen_custom_prompt_seq_additional": "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray. Image 3 represents the overall style.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": True, "lora_units": []},"LOCAL REFINE": {"description": "Uses the SDXL local edit mode to improve detail / refine specific areas. Use new set of cameras or a single camera pointed at the area you want to refine.", "control_after_generate": "fixed", "model_architecture": "sdxl", "steps": 8, "cfg": 1.5, "sampler": "dpmpp_2s_ancestral", "scheduler": "sgm_uniform", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 80.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 3.0, "weight_exponent_generation_only": False, "weight_exponent_after_generation": 15.0, "view_blend_use_color_match": False, "view_blend_color_match_method": "reinhard", "view_blend_color_match_strength": 1.0, "clip_skip": 1, "auto_rescale": True, "auto_rescale_target_mp": 1.0, "overwrite_material": True, "generation_method": "local_edit", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 0.800000011920929, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": True, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.10000000149011612, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": True, "sequential_ipadapter_mode": "original_render", "sequential_desaturate_factor": 0.10000000149011612, "sequential_contrast_factor": 0.10000000149011612, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "early_priority": False, "early_priority_strength": 0.5, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_voronoi_mode": True, "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "REPLACE_STYLE", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Change and transfer the format of '{main_prompt}' in image 1 to the style from image 2", "qwen_custom_prompt_seq_none": "Change and transfer the format of '{main_prompt}' in image 1 to the style from image 2", "qwen_custom_prompt_seq_replace": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas.", "qwen_custom_prompt_seq_additional": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas. Image 3 represents the overall style of the object.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 5.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": True, "refine_angle_ramp_active": True, "refine_angle_ramp_pos_0": 0.0, "refine_angle_ramp_pos_1": 0.05, "visibility_vignette": True, "visibility_vignette_width": 0.3, "visibility_vignette_softness": 1.0, "visibility_vignette_blur": False, "refine_feather_ramp_pos_0": 0.0, "refine_feather_ramp_pos_1": 0.6, "refine_edge_feather_projection": True, "refine_edge_feather_width": 30, "refine_edge_feather_softness": 1.0, "controlnet_units": [{'unit_type': 'depth', 'model_name': 'controlnet_depth_sdxl.safetensors', 'strength': 0.5, 'start_percent': 0.0, 'end_percent': 1.0, 'is_union': False, 'use_union_type': True}], "lora_units": [{'model_name': 'sdxl_lightning_8step_lora.safetensors', 'model_strength': 1.0, 'clip_strength': 1.0}]},"LOCAL EDIT (QWEN)": {"description": "Uses Qwen to make targeted edits to specific areas. Point cameras at what you want to change — you can alter colors, style, rewrite text, add details, and more. Untouched areas are preserved.", "control_after_generate": "fixed", "model_architecture": "qwen_image_edit", "qwen_generation_method": "local_edit", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 3.0, "weight_exponent_generation_only": False, "weight_exponent_after_generation": 15.0, "view_blend_use_color_match": False, "view_blend_color_match_method": "reinhard", "view_blend_color_match_strength": 1.0, "clip_skip": 1, "auto_rescale": True, "auto_rescale_target_mp": 1.0, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": False, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.0, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "early_priority": False, "early_priority_strength": 0.5, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_voronoi_mode": False, "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "REPLACE_STYLE", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Change the format of image 1 to '{main_prompt}'", "qwen_custom_prompt_seq_none": "Change and transfer the format of '{main_prompt}' in image 1 to the style from image 2", "qwen_custom_prompt_seq_replace": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas.", "qwen_custom_prompt_seq_additional": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas. Image 3 represents the overall style of the object.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": False, "refine_angle_ramp_active": False, "refine_angle_ramp_pos_0": 0.0, "refine_angle_ramp_pos_1": 0.05, "visibility_vignette": True, "visibility_vignette_width": 0.1, "visibility_vignette_softness": 1.0, "visibility_vignette_blur": False, "refine_feather_ramp_pos_0": 0.0, "refine_feather_ramp_pos_1": 0.6, "refine_edge_feather_projection": True, "refine_edge_feather_width": 15, "refine_edge_feather_softness": 1.0, "lora_units": [{'model_name': 'Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16.safetensors', 'model_strength': 1.0, 'clip_strength': 0.0}]},"REFINE (QWEN)": {"description": "Uses Qwen to restyle or globally modify the entire existing texture. Applies changes uniformly across all camera views — ideal for changing the overall color scheme, art style, or surface appearance.", "control_after_generate": "fixed", "model_architecture": "qwen_image_edit", "qwen_generation_method": "refine", "steps": 4, "cfg": 1.0, "sampler": "euler", "scheduler": "simple", "fallback_color": mathutils.Color((0.0, 0.0, 0.0)), "discard_factor": 70.0, "discard_factor_generation_only": True, "discard_factor_after_generation": 90.0, "weight_exponent": 3.0, "weight_exponent_generation_only": False, "weight_exponent_after_generation": 15.0, "view_blend_use_color_match": False, "view_blend_color_match_method": "reinhard", "view_blend_color_match_strength": 1.0, "clip_skip": 1, "auto_rescale": True, "auto_rescale_target_mp": 1.0, "overwrite_material": True, "generation_method": "sequential", "refine_images": False, "refine_steps": 8, "refine_sampler": "dpmpp_2s_ancestral", "refine_scheduler": "sgm_uniform", "denoise": 1.0, "refine_cfg": 1.5, "refine_prompt": "", "refine_upscale_method": "lanczos", "sequential_smooth": False, "sequential_custom_camera_order": "", "sequential_factor": 0.699999988079071, "sequential_factor_smooth": 0.15000000596046448, "sequential_factor_smooth_2": 1.0, "sequential_ipadapter": False, "sequential_ipadapter_mode": "first", "sequential_desaturate_factor": 0.0, "sequential_contrast_factor": 0.0, "sequential_ipadapter_regenerate": False, "ipadapter_weight_type": "style", "ipadapter_strength": 1.0, "ipadapter_start": 0.0, "ipadapter_end": 1.0, "early_priority": False, "early_priority_strength": 0.5, "differential_diffusion": True, "differential_noise": True, "blur_mask": True, "blur_mask_radius": 1, "blur_mask_sigma": 1.0, "grow_mask_by": 3, "canny_threshold_low": 0, "canny_threshold_high": 80, "qwen_guidance_map_type": "depth", "qwen_voronoi_mode": False, "qwen_use_external_style_image": False, "qwen_external_style_image": "", "qwen_context_render_mode": "REPLACE_STYLE", "qwen_external_style_initial_only": False, "qwen_use_custom_prompts": False, "qwen_custom_prompt_initial": "Change the format of image 1 to '{main_prompt}'", "qwen_custom_prompt_seq_none": "Change and transfer the format of '{main_prompt}' in image 1 to the style from image 2", "qwen_custom_prompt_seq_replace": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas.", "qwen_custom_prompt_seq_additional": "Change and transfer the format of image 1 to '{main_prompt}'. Replace all solid magenta areas in image 2. Replace the background with solid gray. The style from image 2 should smoothly continue into the previously magenta areas. Image 3 represents the overall style of the object.", "qwen_guidance_fallback_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_guidance_background_color": mathutils.Color((1.0, 0.0, 1.0)), "qwen_context_cleanup": False, "qwen_context_cleanup_hue_tolerance": 0.0, "qwen_context_cleanup_value_adjust": 0.0, "qwen_context_fallback_dilation": 1, "qwen_rescale_alignment": False, "lora_units": [{'model_name': 'Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16.safetensors', 'model_strength': 1.0, 'clip_strength': 0.0}]},@@ -603,7 +607,7 @@ class StableGenPanel(bpy.types.Panel):is_trellis2 = getattr(scene, 'architecture_mode', 'sdxl') == 'trellis2'trellis2_tex_mode = getattr(scene, 'trellis2_texture_mode', 'native')- trellis2_diffusion_texturing = is_trellis2 and trellis2_tex_mode in ('sdxl', 'flux1', 'qwen_image_edit')+ trellis2_diffusion_texturing = is_trellis2 and trellis2_tex_mode in ('sdxl', 'flux1', 'qwen_image_edit', 'flux2_klein')main_params_box = layout.box()main_params_col = main_params_box.column()@@ -954,7 +958,7 @@ class StableGenPanel(bpy.types.Panel):sub_row = unit_box.row(align=True)sub_row.prop(lora_unit, "model_strength", text="Model Strength")- if not scene.model_architecture.startswith("qwen"): # Qwen uses model only loras+ if not scene.model_architecture.startswith("qwen") and scene.model_architecture != 'flux2_klein': # Qwen/Klein use model only lorassub_row.prop(lora_unit, "clip_strength", text="CLIP Strength")# Icon to indicate selection more clearly alongside the alert state@@ -1029,7 +1033,7 @@ class StableGenPanel(bpy.types.Panel):split.prop(scene, "weight_exponent", text="Exponent")# Row 2 & 3: Reset toggles and values (only for sequential / qwen)- if scene.generation_method == 'sequential' or scene.model_architecture == 'qwen_image_edit':+ if scene.generation_method == 'sequential' or scene.model_architecture in ('qwen_image_edit', 'flux2_klein'):split = content_box.split(factor=0.5, align=True)split.prop(scene, "discard_factor_generation_only", text="Reset Angle", toggle=True)split.prop(scene, "weight_exponent_generation_only", text="Reset Exponent", toggle=True)@@ -1174,13 +1178,15 @@ class StableGenPanel(bpy.types.Panel):if _show_diffusion_sections:if scene.model_architecture in ['sdxl', 'flux1']:content_box = draw_collapsible_section(advanced_params_box, "show_image_guidance_settings", "Image Guidance (IPAdapter & ControlNet)", icon="MODIFIER")+ elif scene.model_architecture == 'flux2_klein':+ content_box = draw_collapsible_section(advanced_params_box, "show_image_guidance_settings", "FLUX.2 Klein Guidance", icon="MODIFIER")else: # Qwen Image Editcontent_box = draw_collapsible_section(advanced_params_box, "show_image_guidance_settings", "Qwen-Image-Edit Guidance", icon="MODIFIER")else:content_box = Noneif content_box:- if scene.model_architecture == 'qwen_image_edit':- if scene.qwen_generation_method == 'generate':+ if scene.model_architecture in ('qwen_image_edit', 'flux2_klein'):+ if scene.model_architecture == 'flux2_klein' or scene.qwen_generation_method == 'generate':split = content_box.split(factor=0.5)split.label(text="Guidance Map:")split.prop(scene, "qwen_guidance_map_type", text="")@@ -1398,7 +1404,7 @@ class StableGenPanel(bpy.types.Panel):cn_box.operator("stablegen.add_controlnet_unit", text="Add ControlNet Unit", icon="ADD")cn_box.operator("stablegen.remove_controlnet_unit", text="Remove Last ControlNet Unit", icon="REMOVE")- if _show_diffusion_sections and not scene.model_architecture == 'qwen_image_edit':+ if _show_diffusion_sections and scene.model_architecture not in ('qwen_image_edit', 'flux2_klein'):# --- Inpainting Options (Conditional) ---if scene.generation_method == 'uv_inpaint' or scene.generation_method == 'sequential':content_box = draw_collapsible_section(advanced_params_box, "show_masking_inpainting_settings", "Inpainting Options", icon="MOD_MASK")@@ -1553,7 +1559,7 @@ class StableGenPanel(bpy.types.Panel):sub_ip_box_separate.prop(scene, "sequential_desaturate_factor", text="Desaturate")sub_ip_box_separate.prop(scene, "sequential_contrast_factor", text="Reduce Contrast")- if context.scene.model_architecture != 'qwen_image_edit':+ if context.scene.model_architecture not in ('qwen_image_edit', 'flux2_klein'):split = sub_ip_box_separate.split(factor=0.5)if context.scene.model_architecture == 'sdxl':split.label(text="Weight Type:")@@ -1741,7 +1747,7 @@ class StableGenPanel(bpy.types.Panel):sub_ip_seq_box.prop(scene, "sequential_desaturate_factor", text="Desaturate")sub_ip_seq_box.prop(scene, "sequential_contrast_factor", text="Reduce Contrast")- if context.scene.model_architecture != 'qwen_image_edit':+ if context.scene.model_architecture not in ('qwen_image_edit', 'flux2_klein'):split = sub_ip_seq_box.split(factor=0.5)if context.scene.model_architecture == 'sdxl':split.label(text="Weight Type:")@@ -1834,7 +1840,7 @@ class StableGenPanel(bpy.types.Panel):class ResetQwenPrompt(bpy.types.Operator):- """Resets a Qwen guidance prompt to its default value"""+ """Resets a guidance prompt to its default value"""bl_idname = "stablegen.reset_qwen_prompt"bl_label = "Reset Qwen Prompt"bl_description = "Reset this prompt to its default value based on the current settings"@@ -1847,18 +1853,22 @@ class ResetQwenPrompt(bpy.types.Operator):# This doesn't run generation, just gives us access to the methodwm = WorkflowManager(self)+ # Choose the correct default prompt builder for the active architecture+ is_klein = getattr(context.scene, 'model_architecture', '') == 'flux2_klein'+ get_defaults = wm._get_klein_default_prompts if is_klein else wm._get_qwen_default_prompts+# Determine which prompt to resetif self.prompt_type == 'initial':- default_prompt = wm._get_qwen_default_prompts(context, is_initial_image=True)+ default_prompt = get_defaults(context, is_initial_image=True)context.scene.qwen_custom_prompt_initial = default_promptelif self.prompt_type == 'seq_none':- default_prompt = wm._get_qwen_default_prompts(context, is_initial_image=False)+ default_prompt = get_defaults(context, is_initial_image=False)context.scene.qwen_custom_prompt_seq_none = default_promptelif self.prompt_type == 'seq_replace':- default_prompt = wm._get_qwen_default_prompts(context, is_initial_image=False)+ default_prompt = get_defaults(context, is_initial_image=False)context.scene.qwen_custom_prompt_seq_replace = default_promptelif self.prompt_type == 'seq_additional':- default_prompt = wm._get_qwen_default_prompts(context, is_initial_image=False)+ default_prompt = get_defaults(context, is_initial_image=False)context.scene.qwen_custom_prompt_seq_additional = default_promptself.report({'INFO'}, "Prompt reset to default.")@@ -1922,7 +1932,7 @@ class ApplyPreset(bpy.types.Operator):# include architecture_mode, update the visible dropdown to match.if "architecture_mode" not in values:arch = context.scene.model_architecture- if arch in ('sdxl', 'flux1', 'qwen_image_edit'):+ if arch in ('sdxl', 'flux1', 'qwen_image_edit', 'flux2_klein'):context.scene.architecture_mode = archif skipped:diff --git a/stablegen/util/helpers.py b/stablegen/util/helpers.pyindex f9df1af..67c11b1 100755--- a/stablegen/util/helpers.py+++ b/stablegen/util/helpers.py@@ -1493,6 +1493,150 @@ prompt_text_qwen_image_edit = """}"""+# ---------------------------------------------------------------------------+# FLUX.2 Klein – multi-reference edit model (Apache 2.0)+# Based on official ComfyUI Klein image-edit workflow.+# Nodes: all built-in ComfyUI core (no custom nodes needed)+# UNETLoader, CLIPLoader (type=flux2, Qwen 3 4B), VAELoader,+# CLIPTextEncode (x2), EmptyFlux2LatentImage, Flux2Scheduler,+# KSamplerSelect, RandomNoise, CFGGuider (cfg=1), SamplerCustomAdvanced,+# VAEDecode, SaveImageWebsocket, LoadImage (x3 reference slots).+# Reference images are wired dynamically via:+# VAEEncode → ReferenceLatent (pos + neg chain) → CFGGuider.+# ---------------------------------------------------------------------------+prompt_text_flux2_klein = """+{+ "1": {+ "inputs": {+ "unet_name": "flux-2-klein-base-4b-fp8.safetensors",+ "weight_dtype": "default"+ },+ "class_type": "UNETLoader",+ "_meta": { "title": "Load Diffusion Model (Klein)" }+ },+ "2": {+ "inputs": {+ "clip_name": "qwen_3_4b.safetensors",+ "type": "flux2"+ },+ "class_type": "CLIPLoader",+ "_meta": { "title": "Load CLIP (Qwen 3 4B)" }+ },+ "3": {+ "inputs": {+ "vae_name": "flux2-vae.safetensors"+ },+ "class_type": "VAELoader",+ "_meta": { "title": "Load VAE (FLUX.2)" }+ },+ "4": {+ "inputs": {+ "text": "",+ "clip": ["2", 0]+ },+ "class_type": "CLIPTextEncode",+ "_meta": { "title": "CLIP Text Encode (Positive)" }+ },+ "5": {+ "inputs": {+ "text": "",+ "clip": ["2", 0]+ },+ "class_type": "CLIPTextEncode",+ "_meta": { "title": "CLIP Text Encode (Negative)" }+ },+ "6": {+ "inputs": {+ "width": 1024,+ "height": 1024,+ "batch_size": 1+ },+ "class_type": "EmptyFlux2LatentImage",+ "_meta": { "title": "Empty Flux 2 Latent" }+ },+ "7": {+ "inputs": {+ "steps": 20,+ "width": 1024,+ "height": 1024+ },+ "class_type": "Flux2Scheduler",+ "_meta": { "title": "Flux 2 Scheduler" }+ },+ "8": {+ "inputs": {+ "sampler_name": "euler"+ },+ "class_type": "KSamplerSelect",+ "_meta": { "title": "KSampler Select" }+ },+ "9": {+ "inputs": {+ "noise_seed": 0+ },+ "class_type": "RandomNoise",+ "_meta": { "title": "Random Noise" }+ },+ "10": {+ "inputs": {+ "model": ["1", 0],+ "positive": ["4", 0],+ "negative": ["5", 0],+ "cfg": 1+ },+ "class_type": "CFGGuider",+ "_meta": { "title": "CFG Guider" }+ },+ "11": {+ "inputs": {+ "noise": ["9", 0],+ "guider": ["10", 0],+ "sampler": ["8", 0],+ "sigmas": ["7", 0],+ "latent_image": ["6", 0]+ },+ "class_type": "SamplerCustomAdvanced",+ "_meta": { "title": "Sampler Custom Advanced" }+ },+ "12": {+ "inputs": {+ "samples": ["11", 0],+ "vae": ["3", 0]+ },+ "class_type": "VAEDecode",+ "_meta": { "title": "VAE Decode" }+ },+ "13": {+ "inputs": {+ "images": ["12", 0]+ },+ "class_type": "SaveImageWebsocket",+ "_meta": { "title": "SaveImageWebsocket" }+ },+ "14": {+ "inputs": {+ "image": ""+ },+ "class_type": "LoadImage",+ "_meta": { "title": "Load Reference Image 1 (Structure)" }+ },+ "15": {+ "inputs": {+ "image": ""+ },+ "class_type": "LoadImage",+ "_meta": { "title": "Load Reference Image 2 (Style)" }+ },+ "16": {+ "inputs": {+ "image": ""+ },+ "class_type": "LoadImage",+ "_meta": { "title": "Load Reference Image 3 (Context)" }+ }+}+"""+# Workflow for TRELLIS.2 Image-to-3D generation via PozzettiAndrea/ComfyUI-TRELLIS2 nodes# Pipeline: LoadImage → LoadModels → RemoveBackground → GetConditioning → ImageToShape → ShapeToTexturedMesh → ExportGLBprompt_text_trellis2 = """diff --git a/stablegen/utils.py b/stablegen/utils.pyindex 86dbe19..4dfa06e 100644--- a/stablegen/utils.py+++ b/stablegen/utils.py@@ -352,7 +352,7 @@ def get_file_path(context, file_type, subtype=None, filename=None, camera_id=Nonelif file_type == "inpaint" and subtype:base_dir = dirs["inpaint"][subtype]if subtype == "render":- filename = f"render{camera_id}{frame_suffix}" if not filename else filename+ filename = f"ctx_render{camera_id}{frame_suffix}" if not filename else filenameelif subtype == "visibility":filename = f"render{camera_id}_visibility{frame_suffix}" if not filename else filenamereturn os.path.join(base_dir, f"{filename}.png")diff --git a/stablegen/workflows.py b/stablegen/workflows.pyindex 8befb21..0d2a986 100644--- a/stablegen/workflows.py+++ b/stablegen/workflows.py@@ -10,7 +10,7 @@ import urllib.requestimport urllib.parsefrom datetime import datetime, timedelta-from .util.helpers import prompt_text_qwen_image_edit, prompt_text_trellis2, prompt_text_trellis2_shape_only+from .util.helpers import prompt_text_qwen_image_edit, prompt_text_flux2_klein, prompt_text_trellis2, prompt_text_trellis2_shape_onlyfrom .utils import get_generation_dirsfrom .timeout_config import get_timeout@@ -251,6 +251,124 @@ class WorkflowManager:}prompt[sampler_node]['inputs']['negative'] = [tz_neg_id, 0]+ # ------------------------------------------------------------------+ # FLUX.2 Klein – build ReferenceLatent chain for multi-reference editing+ # ------------------------------------------------------------------+ def _build_flux2_reference_chain(self, prompt, NODES, ref_image_infos, start_node_id=700):+ """Build a ReferenceLatent chain for FLUX.2 Klein (based on official workflow).++ For each reference image, creates:+ LoadImage (already present) → VAEEncode+ → ReferenceLatent (positive conditioning)+ → ReferenceLatent (negative conditioning)++ The ReferenceLatent nodes are chained so each successive reference+ appends to the previous one. The final modified positive and negative+ conditioning outputs are wired into CFGGuider.++ Args:+ prompt: The ComfyUI prompt dict (modified in-place).+ NODES: Node-ID mapping dict.+ ref_image_infos: List of dicts, each with at least a ``loader_node``+ key pointing to the LoadImage node ID.+ start_node_id: First dynamic node ID to use.+ """+ if not ref_image_infos:+ return++ pos_node = NODES['pos_prompt']+ neg_node = NODES['neg_prompt']+ guider_node = NODES['guider']+ vae_ref = [NODES['vae_loader'], 0]++ node_id = start_node_id+ while str(node_id) in prompt:+ node_id += 1++ pos_cond_ref = [pos_node, 0]+ neg_cond_ref = [neg_node, 0]++ for i, ref_info in enumerate(ref_image_infos):+ loader_node = ref_info['loader_node']++ # --- VAEEncode (reference image → latent) ---+ vae_enc_id = str(node_id); node_id += 1+ prompt[vae_enc_id] = {+ "inputs": {+ "pixels": [loader_node, 0],+ "vae": vae_ref+ },+ "class_type": "VAEEncode",+ "_meta": {"title": f"VAE Encode Ref {i + 1}"}+ }++ # --- ReferenceLatent (positive) ---+ ref_pos_id = str(node_id); node_id += 1+ prompt[ref_pos_id] = {+ "inputs": {+ "conditioning": pos_cond_ref,+ "latent": [vae_enc_id, 0]+ },+ "class_type": "ReferenceLatent",+ "_meta": {"title": f"Reference Latent Pos {i + 1}"}+ }+ pos_cond_ref = [ref_pos_id, 0]++ # --- ReferenceLatent (negative) ---+ ref_neg_id = str(node_id); node_id += 1+ prompt[ref_neg_id] = {+ "inputs": {+ "conditioning": neg_cond_ref,+ "latent": [vae_enc_id, 0]+ },+ "class_type": "ReferenceLatent",+ "_meta": {"title": f"Reference Latent Neg {i + 1}"}+ }+ neg_cond_ref = [ref_neg_id, 0]++ # Wire final pos/neg conditioning into CFGGuider+ prompt[guider_node]['inputs']['positive'] = pos_cond_ref+ prompt[guider_node]['inputs']['negative'] = neg_cond_ref++ def _get_klein_default_prompts(self, context, is_initial_image):+ """Gets the default Klein prompts based on the current context.++ Follows BFL's official Klein prompting guide: write like a novelist,+ front-load the subject, reference image numbers explicitly, and+ describe the desired transformation rather than the image contents.+ Camera prompts are placed after the main prompt via {camera_suffix}+ to reduce their weighting (Klein pays more attention to what comes+ first).+ """+ is_generating = hasattr(self.operator, '_current_image')+ is_subsequent_in_sequence = is_generating and self.operator._current_image > 0++ if is_initial_image:+ style_image_provided = context.scene.qwen_use_external_style_image+ else:+ style_image_provided = (+ context.scene.qwen_use_external_style_image or+ context.scene.sequential_ipadapter or+ context.scene.qwen_context_render_mode in {'REPLACE_STYLE', 'ADDITIONAL'}+ )+ context_mode = context.scene.qwen_context_render_mode++ if is_initial_image:+ if not style_image_provided:+ return "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour."+ else:+ return "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour, adopting the visual style from image 2."+ else:+ if context_mode == 'ADDITIONAL':+ return "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray. Image 3 represents the overall style."+ elif context_mode == 'REPLACE_STYLE':+ return "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour. In image 2, replace all solid magenta areas with content that continues the surrounding style. Replace the background with solid gray."+ else:+ if not style_image_provided:+ return "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour."+ else:+ return "Reskin this into {main_prompt}{camera_suffix}, while preserve identity keep likeness replica contour, adopting the visual style from image 2."+def _get_qwen_default_prompts(self, context, is_initial_image):"""Gets the default Qwen prompts based on the current context."""# Check if we are in a real generation context vs. just resetting a prompt@@ -665,6 +783,247 @@ class WorkflowManager:print(f"Qwen image generated with prompt: {prompt[NODES['pos_prompt']]['inputs']['prompt']}")return images[NODES['save_image']][0]++ # ------------------------------------------------------------------+ # FLUX.2 Klein – multi-reference edit generation+ # ------------------------------------------------------------------+ def generate_flux2_klein(self, context, camera_id=None):+ """Generates an image using the FLUX.2 Klein multi-reference edit workflow.++ Klein injects reference images via ReferenceLatent chains and+ understands image references ("image 1", "image 2") in prompts.+ Following BFL's official prompting guide, prompts are written as+ natural prose describing the desired transformation, front-loading+ the subject and referencing images by number.++ Reference layout:+ Ref 1 → structure / guidance map (depth, normal, workbench …)+ Ref 2 → style reference (external image or prev gen)+ Ref 3 → context render (sequential mode only)+ """+ server_address = context.preferences.addons[__package__].preferences.server_address+ client_id = str(uuid.uuid4())+ revision_dir = get_generation_dirs(context)["revision"]++ prompt = json.loads(prompt_text_flux2_klein)++ NODES = {+ 'unet_loader': "1",+ 'clip_loader': "2",+ 'vae_loader': "3",+ 'pos_prompt': "4", # CLIPTextEncode+ 'neg_prompt': "5", # CLIPTextEncode (empty)+ 'empty_latent': "6", # EmptyFlux2LatentImage+ 'scheduler': "7", # Flux2Scheduler+ 'ksampler': "8", # KSamplerSelect+ 'noise': "9", # RandomNoise+ 'guider': "10", # CFGGuider+ 'sampler': "11", # SamplerCustomAdvanced+ 'vae_decode': "12", # VAEDecode+ 'save_image': "13", # SaveImageWebsocket+ 'ref1_loader': "14", # LoadImage – structure (guidance map)+ 'ref2_loader': "15", # LoadImage – style+ 'ref3_loader': "16", # LoadImage – context render+ }++ # --- Resolution (must be multiple of 16 for FLUX.2 latent) ---+ if context.scene.generation_method == 'grid':+ width = self.operator._grid_width+ height = self.operator._grid_height+ else:+ width = context.scene.render.resolution_x+ height = context.scene.render.resolution_y+ width = (width // 16) * 16+ height = (height // 16) * 16+ prompt[NODES['empty_latent']]['inputs']['width'] = width+ prompt[NODES['empty_latent']]['inputs']['height'] = height+ prompt[NODES['scheduler']]['inputs']['width'] = width+ prompt[NODES['scheduler']]['inputs']['height'] = height++ # --- Sampler settings ---+ prompt[NODES['noise']]['inputs']['noise_seed'] = context.scene.seed+ prompt[NODES['scheduler']]['inputs']['steps'] = context.scene.steps+ prompt[NODES['ksampler']]['inputs']['sampler_name'] = context.scene.sampler+ prompt[NODES['guider']]['inputs']['cfg'] = context.scene.cfg++ # --- Model ---+ prompt[NODES['unet_loader']]['inputs']['unet_name'] = context.scene.model_name++ # --- CLIP: Detect 9B vs 4B from model name ---+ # 9B uses a larger Qwen 3 8B text encoder instead of 4B.+ # Default to fp8mixed (8.66 GB) for practical VRAM usage.+ # Full-precision qwen_3_8b.safetensors (16.4 GB) is also compatible.+ # Download from: Comfy-Org/vae-text-encorder-for-flux-klein-9b+ model_lower = context.scene.model_name.lower()+ if '9b' in model_lower:+ prompt[NODES['clip_loader']]['inputs']['clip_name'] = "qwen_3_8b_fp8mixed.safetensors"++ # --- Base user prompt + camera injection ---+ user_prompt = context.scene.comfyui_prompt+ camera_suffix = ""+ if (context.scene.use_camera_prompts+ and self.operator._cameras+ and self.operator._current_image < len(self.operator._cameras)):+ cam_name = self.operator._cameras[self.operator._current_image].name+ prompt_item = next(+ (p for p in context.scene.camera_prompts if p.name == cam_name), None)+ if prompt_item and prompt_item.prompt:+ camera_suffix = f", {prompt_item.prompt}"++ # ─── Collect reference images ────────────────────────────────+ ref_images = []+ remove_ref1 = True+ remove_ref2 = True+ remove_ref3 = True++ is_initial_image = not self.operator._current_image > 0+ context_mode = context.scene.qwen_context_render_mode+ context_render_info = None+ style_image_info = None++ # --- Ref 1: Structure / guidance map (always attempt) ---+ guidance_map_type = context.scene.qwen_guidance_map_type+ guidance_map_info = self.operator._get_uploaded_image_info(+ context, "controlnet", subtype=guidance_map_type, camera_id=camera_id)+ if guidance_map_info:+ prompt[NODES['ref1_loader']]['inputs']['image'] = guidance_map_info['name']+ ref_images.append({'loader_node': NODES['ref1_loader']})+ remove_ref1 = False++ # --- Ref 3: Context render (sequential subsequent only) ---+ # Handled BEFORE Ref 2 so ADDITIONAL mode can swap slot ids (mirrors Qwen).+ remove_context = True+ if not is_initial_image and context_mode != 'NONE':+ context_render_info = self.operator._get_uploaded_image_info(+ context, "inpaint", subtype="render", camera_id=camera_id)+ if not context_render_info:+ self.operator._error = f"Klein context render enabled, but could not find context render for camera {camera_id}."+ return {"error": "conn_failed"}+ if context_render_info and context_mode == 'ADDITIONAL':+ # Swap loaders so context render is Ref 2 and style is Ref 3+ NODES['ref3_loader'], NODES['ref2_loader'] = NODES['ref2_loader'], NODES['ref3_loader']+ prompt[NODES['ref3_loader']]['inputs']['image'] = context_render_info['name']+ ref_images.append({'loader_node': NODES['ref3_loader']})+ remove_context = False+ if context.scene.qwen_use_custom_prompts:+ pos_prompt_text = context.scene.qwen_custom_prompt_seq_additional.format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ else:+ pos_prompt_text = self._get_klein_default_prompts(context, is_initial_image).format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ prompt[NODES['pos_prompt']]['inputs']['text'] = pos_prompt_text++ if remove_context and not remove_ref3:+ pass # already assigned+ elif remove_context:+ pass # will be deleted below++ # --- Ref 2: Style reference (optional) ---+ # Determine if we should use the external style image for this frame+ use_external = context.scene.qwen_use_external_style_image+ if use_external and not is_initial_image and context.scene.qwen_external_style_initial_only:+ use_external = False+ context.scene.sequential_ipadapter = True++ # Case 1: External Style Image+ if use_external:+ style_image_info = self.operator._get_uploaded_image_info(+ context, "custom",+ filename=bpy.path.abspath(context.scene.qwen_external_style_image))+ if style_image_info and context_mode != 'ADDITIONAL':+ if context.scene.qwen_use_custom_prompts:+ pos_prompt_text = (context.scene.qwen_custom_prompt_initial if is_initial_image+ else context.scene.qwen_custom_prompt_seq_none).format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ else:+ pos_prompt_text = self._get_klein_default_prompts(context, is_initial_image).format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ prompt[NODES['pos_prompt']]['inputs']['text'] = pos_prompt_text++ # Case 1b: TRELLIS.2 input image as style+ if not style_image_info and getattr(context.scene, 'qwen_use_trellis2_style', False):+ use_t2 = True+ if not is_initial_image and getattr(context.scene, 'qwen_trellis2_style_initial_only', False):+ use_t2 = False+ context.scene.sequential_ipadapter = True+ if use_t2:+ t2_path = getattr(context.scene, 'trellis2_last_input_image', '')+ if t2_path and os.path.exists(bpy.path.abspath(t2_path)):+ style_image_info = self.operator._get_uploaded_image_info(+ context, "custom", filename=bpy.path.abspath(t2_path))+ if style_image_info:+ if context.scene.qwen_use_custom_prompts:+ pos_prompt_text = context.scene.qwen_custom_prompt_initial.format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ else:+ pos_prompt_text = self._get_klein_default_prompts(context, is_initial_image).format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ prompt[NODES['pos_prompt']]['inputs']['text'] = pos_prompt_text++ # Case 2: Sequential (after first image)+ if not style_image_info and not is_initial_image:+ if context_mode == 'REPLACE_STYLE':+ style_image_info = context_render_info+ if context.scene.qwen_use_custom_prompts:+ pos_prompt_text = context.scene.qwen_custom_prompt_seq_replace.format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ else:+ pos_prompt_text = self._get_klein_default_prompts(context, is_initial_image).format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ prompt[NODES['pos_prompt']]['inputs']['text'] = pos_prompt_text+ elif context.scene.sequential_ipadapter:+ if context.scene.sequential_ipadapter_mode == 'original_render':+ # For original_render in Klein context, fall back to first mode since+ # the render is already used as the guidance map (Ref 1).+ ref_cam = 0+ else:+ ref_cam = (0 if context.scene.sequential_ipadapter_mode == 'first'+ else self.operator._current_image - 1)+ style_image_info = self.operator._get_uploaded_image_info(+ context, "generated", camera_id=ref_cam,+ material_id=self.operator._material_id)+ if context_mode != 'ADDITIONAL':+ if context.scene.qwen_use_custom_prompts:+ pos_prompt_text = context.scene.qwen_custom_prompt_seq_none.format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ else:+ pos_prompt_text = self._get_klein_default_prompts(context, is_initial_image).format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ prompt[NODES['pos_prompt']]['inputs']['text'] = pos_prompt_text++ # Case 3: No style image – first image or no style source+ if style_image_info is None:+ if context.scene.qwen_use_custom_prompts:+ pos_prompt_text = (context.scene.qwen_custom_prompt_initial if is_initial_image+ else context.scene.qwen_custom_prompt_seq_none).format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ else:+ pos_prompt_text = self._get_klein_default_prompts(context, is_initial_image).format(main_prompt=user_prompt, camera_suffix=camera_suffix)+ prompt[NODES['pos_prompt']]['inputs']['text'] = pos_prompt_text+ else:+ prompt[NODES['ref2_loader']]['inputs']['image'] = style_image_info['name']+ ref_images.append({'loader_node': NODES['ref2_loader']})+ remove_ref2 = False++ # Remove unused LoadImage nodes+ if remove_ref1:+ del prompt[NODES['ref1_loader']]+ if remove_ref2:+ del prompt[NODES['ref2_loader']]+ if remove_context:+ del prompt[NODES['ref3_loader']]++ # --- Build ReferenceLatent chain ---+ self._build_flux2_reference_chain(prompt, NODES, ref_images)++ # --- Execute ---+ self._save_prompt_to_file(prompt, revision_dir)+ ws = self._connect_to_websocket(server_address, client_id)+ if ws is None:+ return {"error": "conn_failed"}++ images = None+ try:+ images = self._execute_prompt_and_get_images(+ ws, prompt, client_id, server_address, NODES)+ finally:+ if ws:+ ws.close()++ if images is None or (isinstance(images, dict) and "error" in images):+ return {"error": "conn_failed"}++ print(f"FLUX.2 Klein image generated with prompt: {prompt[NODES['pos_prompt']]['inputs']['text']}")+ return images[NODES['save_image']][0]def generate(self, context, controlnet_info=None, ipadapter_ref_info=None):