reference

This commit is contained in:
Haoming 2026-04-10 11:38:30 +08:00
parent 21555e53de
commit c29f39628c
2 changed files with 12 additions and 3 deletions

View File

@ -14,6 +14,7 @@ from backend.patcher.clip import CLIP
from backend.patcher.unet import UnetPatcher
from backend.patcher.vae import VAE
from backend.text_processing.klein_engine import KleinTextProcessingEngine
from modules.shared import opts
class Flux2(ForgeDiffusionEngine):
@ -62,6 +63,9 @@ class Flux2(ForgeDiffusionEngine):
sample = self.forge_objects.vae.encode(x.movedim(1, -1) * 0.5 + 0.5)
sample = self.forge_objects.vae.first_stage_model.process_in(sample)
if opts.klein_no_reference:
return sample.to(x)
if dynamic_args.is_referencing:
self.ref_latents.append(sample.cpu())
else:

View File

@ -4,7 +4,7 @@ import gradio as gr
from backend.text_processing import emphasis as sd_emphasis
from modules import localization, shared, shared_gradio_themes, shared_items, ui_components, util
from modules.options import OptionDiv, OptionHTML, OptionInfo, categories, options_section
from modules.options import OptionDiv, OptionHTML, OptionInfo, OptionRow, categories, options_section
from modules.paths_internal import data_path, default_output_dir
from modules.shared_cmd_options import cmd_opts
from modules_forge import presets as forge_presets
@ -227,10 +227,14 @@ options_templates.update(
"tiling": OptionInfo(False, "Tiling", infotext="Tiling").info("produce a tileable image"),
"randn_source": OptionInfo("CPU", "Random Number Generator", gr.Radio, {"choices": ("CPU", "GPU", "NV")}, infotext="RNG").info("use <b>CPU</b> for the maximum recreatability across different systems"),
"divxl": OptionDiv(),
"sdxl_01": OptionRow(),
"sdxl_crop_top": OptionInfo(0, "[SDXL] Crop-Top Coordinate"),
"sdxl_crop_left": OptionInfo(0, "[SDXL] Crop-Left Coordinate"),
"sdxl_00": OptionRow(),
"sdxl_11": OptionRow(),
"sdxl_refiner_low_aesthetic_score": OptionInfo(2.5, "[SDXL] Low Aesthetic Score", gr.Number),
"sdxl_refiner_high_aesthetic_score": OptionInfo(6.0, "[SDXL] High Aesthetic Score", gr.Number),
"sdxl_10": OptionRow(),
"divlumina": OptionDiv(),
"neta_template_positive": OptionInfo(
"You are an assistant designed to generate anime images with the highest degree of image-text alignment based on danbooru tags. <Prompt Start>",
@ -244,8 +248,9 @@ options_templates.update(
gr.Textbox,
{"lines": 3, "max_lines": 6, "placeholder": "<Prompt Start>"},
),
"divqwen": OptionDiv(),
"qwen_vae_resize": OptionInfo(False, "Resize input image to 1 megapixel for Qwen-Image-Edit ref_latent"),
"divmisc": OptionDiv(),
"qwen_vae_resize": OptionInfo(False, "[Qwen-Image-Edit] Resize input image to 1 megapixel for ref_latent"),
"klein_no_reference": OptionInfo(False, "[Klein] Disable Reference").info("disable Edit ; enable img2img").info("pin to <b>Quicksettings</b> is recommended if changed often"),
},
)
)