black-forest-labs / flux

Official inference repo for FLUX.1 models
Apache License 2.0
16.18k stars 1.17k forks source link

TypeError: load_checkpoint_and_dispatch() got an unexpected keyword argument 'strict' #134

Open CODERConfused opened 2 months ago

CODERConfused commented 2 months ago

``model_id = "black-forest-labs/FLUX.1-schnell" # you can also useblack-forest-labs/FLUX.1-dev

pipe = FluxPipeline.from_pretrained( "black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16 )

pipe.enable_model_cpu_offload() # save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power

prompt = "A cat holding a sign that says hello world" seed = 42 image = pipe( prompt, output_type="pil", num_inference_steps=4, # use a larger number if you are using [dev] generator=torch.Generator("cpu").manual_seed(seed), ).images[0] image.save("flux-schnell.png")```

When I try to run this code, this error appears:

Loading pipeline components...:  86%  6/7 [00:01<00:00,  4.05it/s] You set add_prefix_space. The tokenizer needs to be converted from the slow tokenizers Loading checkpoint shards: 100%  2/2 [00:00<00:00,  3.75it/s]

TypeError Traceback (most recent call last) Cell In[2], line 3 1 model_id = "black-forest-labs/FLUX.1-schnell" # you can also use black-forest-labs/FLUX.1-dev ----> 3 pipe = FluxPipeline.from_pretrained( 4 "black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16 5 ) 6 #pipe.enable_model_cpu_offload() # save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power 8 prompt = "A cat holding a sign that says hello world"

File c:\Users\Home7\AppData\Local\Programs\Python\Python312\Lib\site-packages\huggingface_hub\utils_validators.py:114, in validate_hf_hub_args.._inner_fn(*args, *kwargs) 111 if check_use_auth_token: 112 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs) --> 114 return fn(args, **kwargs)

File c:\Users\Home7\AppData\Local\Programs\Python\Python312\Lib\site-packages\diffusers\pipelines\pipeline_utils.py:859, in DiffusionPipeline.from_pretrained(cls, pretrained_model_name_or_path, **kwargs) 856 loaded_sub_model = passed_class_obj[name] 857 else: 858 # load sub model --> 859 loaded_sub_model = load_sub_model( 860 library_name=library_name, 861 class_name=class_name, 862 importable_classes=importable_classes, 863 pipelines=pipelines, 864 is_pipeline_module=is_pipeline_module, ... 792 # names to the new non-deprecated names. Then we greatly encourage the user to convert 793 # the weights so we don't have to do this again. 795 if "'Attention' object has no attribute" in str(e):

TypeError: load_checkpoint_and_dispatch() got an unexpected keyword argument 'strict'

Can you please help? Thank you in advance.

henbucuoshanghai commented 2 months ago

load_checkpoint_and_dispatch() got an unexpected keyword argument 'strict' same error

Qjrun commented 2 months ago

pip install accelerate -U

iamargentum commented 2 months ago

thanks @Qjrun ! this totally worked!