"""Official Turbo 8-step schedule with a standard (non-Heretic) text encoder.""" MODEL='Qwen-Image-2.1-Turbo' SIGMAS=(1.0,0.978453,0.95418,0.926626,0.89508,0.845148,0.704534,0.414568,0.0) DIT='qwen_image_2.1_turbo_int8_convrot.safetensors' ENCODER='qwen3vl_8b_w4a8.safetensors' VAE='qwen_image_2.1_vae_bf16.safetensors' def workflow(prompt,*,width=512,height=512,seed=42,output_prefix='ImageTurbo',skip_negative=True,images=None): if not isinstance(prompt,str) or not prompt.strip() or len(prompt)>10000:raise ValueError('Invalid prompt') if any(type(v) is not int or v%32 or not 256<=v<=2048 for v in (width,height)):raise ValueError('Invalid image dimensions') if type(seed) is not int or not 0<=seed<2**63:raise ValueError('Invalid seed') if images is not None and (not isinstance(images,list) or not 1<=len(images)<=4):raise ValueError('Supply 1–4 reference images') graph={ '1':{'class_type':'UNETLoader','inputs':{'unet_name':DIT,'weight_dtype':'default'}}, '2':{'class_type':'CLIPLoader','inputs':{'clip_name':ENCODER,'type':'qwen_image'}}, '3':{'class_type':'VAELoader','inputs':{'vae_name':VAE}}, '4':{'class_type':'TextEncodeQwenImage21','inputs':{'clip':['2',0],'prompt':prompt,'negative_prompt':'','resolution':width,'skip_negative_for_cfg1':skip_negative}}, '5':{'class_type':'EmptyLatentImage','inputs':{'width':width,'height':height,'batch_size':1}}, '6':{'class_type':'SamplerCustom','inputs':{'model':['1',0],'positive':['4',0],'negative':['4',1],'latent_image':['5',0],'noise_seed':seed,'add_noise':True,'cfg':1.0,'sampler':['9',0],'sigmas':['10',0]}}, '7':{'class_type':'VAEDecode','inputs':{'samples':['6',0],'vae':['3',0]}}, '8':{'class_type':'SaveImage','inputs':{'images':['7',0],'filename_prefix':output_prefix}}, '9':{'class_type':'KSamplerSelect','inputs':{'sampler_name':'euler'}}, '10':{'class_type':'ManualSigmas','inputs':{'sigmas':', '.join(str(x) for x in SIGMAS)}}, } if images: graph['4']['inputs']['vae']=['3',0] graph['4']['inputs']['resolution']=0 graph['6']['inputs']['latent_image']=['4',2] for index,name in enumerate(images,1): if not isinstance(name,str) or '/' in name or '\\' in name or name in ('.','..'):raise ValueError('Reference image must be an uploaded basename') key=str(20+index) graph[key]={'class_type':'LoadImage','inputs':{'image':name}} graph['4']['inputs']['images.image_'+str(index)]=[key,0] return graph