Support FLUX reference images through real edit workflow

This commit is contained in:
Mikei386 committed 2026-10-01 13:47:36 +02:00
1 parent 66e974291d
commit 508a3f4176
5 files changed
+39 -6

No files matched your search

+17 -2
View File
@@ -46,9 +46,10 @@ def select_gpus(devices,model_size,encoder_size,vae_size,offload=False):
return max(images,key=lambda g:g['free_mib']),encoders[0]
def workflow(prompt,params,seed,family='qwen',references=()):
if references and family!='qwen':raise ValueError('Dieses Bildprofil unterstützt keine Referenzbilder.')
if family not in ('qwen','flux'):raise ValueError('Für diese Modellfamilie fehlt eine Bildlaufzeit-Anbindung.')
if len(references)>4:raise ValueError('Maximal vier Referenzbilder pro Auftrag.')
if family=='flux':
return {
graph={
'1':{'class_type':'UNETLoader','inputs':{'unet_name':'model.safetensors','weight_dtype':'default'}},
'2':{'class_type':'DeckTextEncoderLoader','inputs':{'clip_name':'encoder.safetensors','family':'flux2'}},
'3':{'class_type':'VAELoader','inputs':{'vae_name':'vae.safetensors'}},
@@ -64,6 +65,20 @@ def workflow(prompt,params,seed,family='qwen',references=()):
'13':{'class_type':'ConditioningZeroOut','inputs':{'conditioning':['4',0]}}
}
# FLUX.2 editing uses reference latents on both conditioning branches,
# with fresh output noise; never silently discard uploaded references.
positive=['4',0];negative=['13',0]
for index,name in enumerate(references):
load,scale,encode,pos,neg=map(str,range(20+index*5,25+index*5))
graph[load]={'class_type':'LoadImage','inputs':{'image':name}}
graph[scale]={'class_type':'ImageScaleToTotalPixels','inputs':{'image':[load,0],'upscale_method':'lanczos','megapixels':1.0,'resolution_steps':1}}
graph[encode]={'class_type':'VAEEncode','inputs':{'pixels':[scale,0],'vae':['3',0]}}
graph[pos]={'class_type':'ReferenceLatent','inputs':{'conditioning':positive,'latent':[encode,0]}}
graph[neg]={'class_type':'ReferenceLatent','inputs':{'conditioning':negative,'latent':[encode,0]}}
positive=[pos,0];negative=[neg,0]
graph['10']['inputs'].update(positive=positive,negative=negative)
return graph
graph={
'1':{'class_type':'UnetLoaderGGUF','inputs':{'unet_name':'model.gguf'}},
'2':{'class_type':'DeckTextEncoderLoader','inputs':{'clip_name':'encoder.safetensors'}},