When using the KSampler in ComfyUI for generation, the image still becomes blurry when CFG is greater than 1.
I ran into this also. The reason is because the model includes guidance weights, though they are optional. The model works fine with CFG>1 when guidance is bypassed.
The issue is that ComfyUI sees the guidance weights in the state_dict, and loads the model as Flux-dev architecture. Which is the correct thing to do btw, since you can use guidance with the model. So guidance embedding will always be applied. In your workflow, the guidance value is either defaulting to something, or it's 0, either way that's not the same as bypassing guidance.
I wrote a quick python script to remove the guidance weights from the state_dict. Now ComfyUI loads the model as schnell architecture, which is identical to dev except there's no guidance embedding (i.e. the same as guidance being bypassed). Now the model works fine with CFG alone, without any oversaturation / blur / frying of the image. Here's the script if you want it:
import argparse
from pathlib import Path
from safetensors import safe_open
from safetensors.torch import save_file
parser = argparse.ArgumentParser()
parser.add_argument('--input', type=Path, required=True, help='Path to safetensors file')
args = parser.parse_args()
if __name__ == '__main__':
sd = {}
with safe_open(args.input, framework='pt', device='cpu') as f:
metadata = f.metadata()
for k in f.keys():
if k.startswith('vae') or k.startswith('text_encoders'):
continue
if 'guidance_in' in k:
continue
sd[k] = f.get_tensor(k)
output_path = args.input.with_stem(args.input.stem + '-no-guidance')
save_file(sd, output_path, metadata=metadata)
Ideally some node or option should be added to ComfyUI to allow bypassing the guidance embedding for flux dev models.
Awesome, thanks for the script!
Looks like this officially landed in https://github.com/comfyanonymous/ComfyUI/commit/fb2ad645a3a374bb1d0a5e6be2d9dff481cf4cfb so no need to use that convert script any more.
Hi, everyone. Is it possible to share an example workflow of flex.1-alpha gguf? Don't know how to use the 'FluxDisableGuidance'. Thanks!