open-mmlab / mmagic

OpenMMLab Multimodal Advanced, Generative, and Intelligent Creation Toolbox. Unlock the magic 🪄: Generative-AI (AIGC), easy-to-use APIs, awsome model zoo, diffusion models, for text-to-image generation, image/video restoration/enhancement, etc.
https://mmagic.readthedocs.io/en/latest/
Apache License 2.0
6.89k stars 1.06k forks source link

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?[Bug] #2089

Open alexbespik opened 9 months ago

alexbespik commented 9 months ago

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

main branch https://github.com/open-mmlab/mmagic

Environment

virtualenv Linux manjaro kde

Reproduces the problem - code sample

Traceback (most recent call last): File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/gradio_PowerPaint.py", line 37, in torch.load('./models/unet/diffusion_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 986, in load with _open_file_like(f, 'rb') as opened_file: ^^^^^^^^^^^^^^^^^^^^^^^^ File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/power/lib/python3.11/site-packages/torch/serialization.py", line 435, in _open_file_like return _open_file(name_or_buffer, mode) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/power/lib/python3.11/site-packages/torch/serialization.py", line 416, in init super().init(open(name, mode)) ^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: './models/unet/diffusion_pytorch_model.bin'

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'.

Reproduces the problem - command or script

python gradio_PowerPaint.py

Reproduces the problem - error message

Traceback (most recent call last): File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/gradio_PowerPaint.py", line 37, in torch.load('./models/unet/diffusion_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 986, in load with _open_file_like(f, 'rb') as opened_file: ^^^^^^^^^^^^^^^^^^^^^^^^ File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/power/lib/python3.11/site-packages/torch/serialization.py", line 435, in _open_file_like return _open_file(name_or_buffer, mode) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/mmagic/projects/powerpaint/power/lib/python3.11/site-packages/torch/serialization.py", line 416, in init super().init(open(name, mode)) ^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: './models/unet/diffusion_pytorch_model.bin'

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'.

Additional information

all standard

barepixels commented 9 months ago

New user here. Want to report that I have the same problem "python gradio_PowerPaint.py, it looks for a .bin file in models/unet folder"

Areson251 commented 3 months ago

Did solve this issue?