Converting the checkpoint model file to the Diffusers format
Loading checkpoint model data from a .ckpt
or safetensors
file is slow compared with the Diffusers format because every time we load a .ckpt
or safetensors
file, Diffusers will unpack and convert the file to the Diffusers format. To save the conversion every time we load a model file, we may consider converting checkpoint files to the Diffusers format.
We can use the following code to convert a .ckpt
file to the Diffusers format:
ckpt_checkpoint_path = r"D:\temp\anythingV3_fp16.ckpt" target_part = r"D:\temp\anythingV3_fp16" pipe = download_from_original_stable_diffusion_ckpt( ckpt_checkpoint_path, from_safetensors = False, device = "cuda:0" ) pipe.save_pretrained(target_part)
To convert a safetensors
file to the Diffusers format, simply change the from_safetensors
parameter to True
as shown in the following sample...