Code is looking for .bin file

#2
by fromnovelai - opened

When I run python gradio_PowerPaint.py, it looks for a .bin file in models/unet folder. But the model is a .safetensors file, changing the extension to .bin causes a pickle error. Any workaround?

Yeah, I'm seeing this too. Looks like there was a .bin but it was deleted. Changing the code to reference a .safetensors file also seems to cause a pickle error.

fix (open) was provided (https://github.com/open-mmlab/mmagic/pull/2088/commits/52b59c343443a2533c9724170f26bb653a817b46 ) but cannot get it to work (see error) despite the safetensors being in the right models/unet folder..
Get FileNotFoundError for safetensors file

After "fixing" .bin model load error, I'm getting this:
Traceback (most recent call last):
File "****\mmagic\projects\powerpaint\gradio_PowerPaint.py", line 37, in
torch.load('./models/unet/diffusion_pytorch_model.safetensors'), strict=False)
File "****\mmagic\projects\powerpaint\PowerPaint\lib\site-packages\torch\serialization.py", line 1028, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "****\mmagic\projects\powerpaint\PowerPaint\lib\site-packages\torch\serialization.py", line 1246, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '\xe8'.

fix (open) was provided (https://github.com/open-mmlab/mmagic/pull/2088/commits/52b59c343443a2533c9724170f26bb653a817b46 ) but cannot get it to work (see error) despite the safetensors being in the right models/unet folder..
Get FileNotFoundError for safetensors file

I have same problem :
When i use fix - Traceback (most recent call last):
File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/gradio_PowerPaint.py", line 38, in
load_file('./models/unet/diffusion_pytorch_model.safetensors', device='cuda'), strict=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/power/lib/python3.11/site-packages/safetensors/torch.py", line 308, in load_file
with safe_open(filename, framework="pt", device=device) as f:

     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge

fix (open) was provided (https://github.com/open-mmlab/mmagic/pull/2088/commits/52b59c343443a2533c9724170f26bb653a817b46 ) but cannot get it to work (see error) despite the safetensors being in the right models/unet folder..
Get FileNotFoundError for safetensors file

I have same problem :
When i use fix - Traceback (most recent call last):
File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/gradio_PowerPaint.py", line 38, in
load_file('./models/unet/diffusion_pytorch_model.safetensors', device='cuda'), strict=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/power/lib/python3.11/site-packages/safetensors/torch.py", line 308, in load_file
with safe_open(filename, framework="pt", device=device) as f:

     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge

if i download .bin file - Traceback (most recent call last):
File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/gradio_PowerPaint.py", line 39, in
torch.load('./models/text_encoder/pytorch_model.bin'), strict=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/power/lib/python3.11/site-packages/torch/serialization.py", line 1028, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/power/lib/python3.11/site-packages/torch/serialization.py", line 1246, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.UnpicklingError: invalid load key, 'v'.

That fix is not reviewed or merged yet

fix (open) was provided (https://github.com/open-mmlab/mmagic/pull/2088/commits/52b59c343443a2533c9724170f26bb653a817b46 ) but cannot get it to work (see error) despite the safetensors being in the right models/unet folder..
Get FileNotFoundError for safetensors file

When I run this .py, this is the error I get:

(base) PS D:\AI\mmagic\projects\powerpaint> python gradio_PowerPaint.py
Traceback (most recent call last):
File "D:\AI\mmagic\projects\powerpaint\gradio_PowerPaint.py", line 3, in
import cv2
ModuleNotFoundError: No module named 'cv2'

ENV: Win10 Python 3.10 Torch 2.1.0+cu118

Using the code from https://github.com/zhuang2002/PowerPaint gradio_PowerPaint.py
And changing line 38 from /models/unet/ to /models/text_encoder/, so that lines 37 and 38 are now:

| load_model(pipe.unet, "./models/unet/unet.safetensors")
| load_model(pipe.text_encoder, "./models/text_encoder/text_encoder.safetensors")

7 pipeline components load without trouble, but then I receive the error:

| RuntimeError: Error(s) in loading state_dict for CLIPTextModel:
| Unexpected key(s) in state_dict: "text_model.embeddings.position_ids"

any fix for this? When I follow the steps I'm getting:

vae\diffusion_pytorch_model.safetensors not found
Loading pipeline components...: 0%| | 0/7 [00:00<?, ?it/s]text_config_dict is provided which will be used to initialize CLIPTextConfig. The value text_config["id2label"] will be overriden.
text_config_dict is provided which will be used to initialize CLIPTextConfig. The value text_config["bos_token_id"] will be overriden.
text_config_dict is provided which will be used to initialize CLIPTextConfig. The value text_config["eos_token_id"] will be overriden.
Loading pipeline components...: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7/7 [00:06<00:00, 1.12it/s]
01/17 09:20:05 - mmengine - INFO - Successfully add external embeddings: P_ctxt, P_shape, P_obj.
01/17 09:20:05 - mmengine - INFO - Successfully add trainable external embeddings: P_ctxt, P_shape, P_obj
Traceback (most recent call last):
File "D:\SDXL\mmagic\projects\powerpaint\gradio_PowerPaint.py", line 36, in
load_model(pipe.unet, './models/unet/diffusion_pytorch_model.safetensors')
File "C:\Users\alexg\miniconda3\envs\PowerPaint\lib\site-packages\safetensors\torch.py", line 197, in load_model
state_dict = load_file(filename)
File "C:\Users\alexg\miniconda3\envs\PowerPaint\lib\site-packages\safetensors\torch.py", line 308, in load_file
with safe_open(filename, framework="pt", device=device) as f:
FileNotFoundError: No such file or directory: "./models/unet/diffusion_pytorch_model.safetensors"

Sign up or log in to comment