Spaces:
Running
on
Zero
Cannot load "lumiere_flux_alpha-fp8.safetensors" with "FluxTransformer2DModel.from_single_file"
Thank you for your scripts. However, when I try to load "lumiere_flux_alpha-fp8.safetensors" with the follow scripts:
import torch
from diffusers import FluxControlPipeline, FluxTransformer2DModel
transformer = FluxTransformer2DModel.from_single_file(
"./lumiere/lumiere_flux_alpha-fp8.safetensors",
torch_dtype=torch.bfloat16
)
An error has occurred:
KeyError Traceback (most recent call last)
Cell In[2], line 4
1 import torch
2 from diffusers import FluxControlPipeline, FluxTransformer2DModel
----> 4 transformer = FluxTransformer2DModel.from_single_file(
5 "./lumiere/lumiere_flux_alpha-fp8.safetensors",
6 torch_dtype=torch.bfloat16
7 )
8 pipe = FluxControlPipeline.from_pretrained("./flux", torch_dtype=torch.bfloat16).to("cuda")
9 pipe.load_lora_weights("./depth_lora", adapter_name="depth")
File ~/miniconda3/lib/python3.12/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 ~/miniconda3/lib/python3.12/site-packages/diffusers/loaders/single_file_model.py:291, in FromOriginalModelMixin.from_single_file(cls, pretrained_model_link_or_path_or_dict, **kwargs)
283 raise ValueError(
284 (
285 "Invalid config
argument. Please provide a string representing a repo id"
286 "or path to a local Diffusers model repo."
287 )
288 )
290 else:
--> 291 config = fetch_diffusers_config(checkpoint)
292 default_pretrained_model_config_name = config["pretrained_model_name_or_path"]
294 if "default_subfolder" in mapping_functions:
File ~/miniconda3/lib/python3.12/site-packages/diffusers/loaders/single_file_utils.py:643, in fetch_diffusers_config(checkpoint)
642 def fetch_diffusers_config(checkpoint):
--> 643 model_type = infer_diffusers_model_type(checkpoint)
644 model_path = DIFFUSERS_DEFAULT_PIPELINE_PATHS[model_type]
645 model_path = copy.deepcopy(model_path)
File ~/miniconda3/lib/python3.12/site-packages/diffusers/loaders/single_file_utils.py:598, in infer_diffusers_model_type(checkpoint)
594 elif any(key in checkpoint for key in CHECKPOINT_KEY_NAMES["flux"]):
595 if any(
596 g in checkpoint for g in ["guidance_in.in_layer.bias", "model.diffusion_model.guidance_in.in_layer.bias"]
597 ):
--> 598 if checkpoint["img_in.weight"].shape[1] == 384:
599 model_type = "flux-fill"
601 elif checkpoint["img_in.weight"].shape[1] == 128:
KeyError: 'img_in.weight'
Could you give me any advise? Many thanks!
My version of diffusers==0.32.1.
Hi. I think the issues caused by the 285 "Invalid config argument. Please provide a string representing a repo id"
If you want to load the local safetensors, a config param needed.transformer = FluxTransformer2DModel.from_single_file("/lumiere/lumiere_flux_alpha-fp8.safetensors", config='/flux-dev/transformer/config.json', torch_dtype=torch.float16)
Hi. I think the issues caused by the
285 "Invalid config argument. Please provide a string representing a repo id"
If you want to load the local safetensors, a config param needed.transformer = FluxTransformer2DModel.from_single_file("/lumiere/lumiere_flux_alpha-fp8.safetensors", config='/flux-dev/transformer/config.json', torch_dtype=torch.float16)
Great! Thank you so much for your help! Now this code can run on my own device! :D