qinghew / CharacterFactory

🔥 CharacterFactory: Sampling Consistent Characters with GANs for Diffusion Models
https://qinghew.github.io/CharacterFactory/
Apache License 2.0
189 stars 14 forks source link

Can‘t run local demo, pickle.UnpicklingError: invalid load key, 'v'. #4

Open emptystack1024 opened 1 month ago

emptystack1024 commented 1 month ago

我运行: python app.py --pretrained_model_name_or_path /home/ubuntu/文档/GitHub/CharacterFactory/stable-diffusion-2-1

但是无法成功运行: image

报错信息: (IDEGAN) ubuntu@ubuntu-all-series:~/文档/GitHub/CharacterFactory$ python app.py --pretrained_model_name_or_path /home/ubuntu/文档/GitHub/CharacterFactory/stable-diffusion-2-1 Loading pipeline components...: 100%|█████████████| 6/6 [00:00<00:00, 7.01it/s] [all_embeddings loaded] shape = torch.Size([326, 2, 1024]) max: tensor(0.0551, device='cuda:0') min={} tensor(-0.0558, device='cuda:0') [name_emb_mean loaded] shape = torch.Size([2, 1024]) max: tensor(0.0167, device='cuda:0') min={} tensor(-0.0085, device='cuda:0') now experiment_name: normal_GAN [all_embeddings loaded] shape = torch.Size([226, 2, 1024]) max: tensor(0.0551, device='cuda:0') min={} tensor(-0.0558, device='cuda:0') [name_emb_mean loaded] shape = torch.Size([2, 1024]) max: tensor(0.0187, device='cuda:0') min={} tensor(-0.0092, device='cuda:0') now experiment_name: man_GAN [all_embeddings loaded] shape = torch.Size([100, 2, 1024]) max: tensor(0.0527, device='cuda:0') min={} tensor(-0.0484, device='cuda:0') [name_emb_mean loaded] shape = torch.Size([2, 1024]) max: tensor(0.0131, device='cuda:0') min={} tensor(-0.0100, device='cuda:0') now experiment_name: woman_GAN Running on local URL: http://127.0.0.1:7860

To create a public link, set share=True in launch(). experiment_name: man_GAN Traceback (most recent call last): File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/gradio/queueing.py", line 541, in process_events response = await route_utils.call_process_api( File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/gradio/route_utils.py", line 276, in call_process_api output = await app.get_blocks().process_api( File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/gradio/blocks.py", line 1928, in process_api result = await self.call_function( File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/gradio/blocks.py", line 1526, in call_function prediction = await utils.async_iteration(iterator) File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/gradio/utils.py", line 657, in async_iteration return await iterator.anext() File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/gradio/utils.py", line 650, in anext return await anyio.to_thread.run_sync( File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread return await future File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 859, in run result = context.run(func, *args) File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/gradio/utils.py", line 633, in run_sync_iterator_async return next(iterator) File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/gradio/utils.py", line 816, in gen_wrapper response = next(iterator) File "app.py", line 198, in generate_image Embedding_Manager.load(embedding_path) File "/home/ubuntu/文档/GitHub/CharacterFactory/models/embedding_manager.py", line 126, in load ckpt = torch.load(ckpt_path, map_location='cuda') File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/torch/serialization.py", line 815, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "/home/ubuntu/anaconda3/envs/IDEGAN/lib/python3.8/site-packages/torch/serialization.py", line 1033, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) _pickle.UnpicklingError: invalid load key, 'v'. ^CKeyboard interruption in main thread... closing server.

qinghew commented 1 month ago

please check the embedding_path

qinghew commented 1 month ago

btw, if your path includes chinese word, it might cause some errors.

emptystack1024 commented 1 month ago

image 您好,抱歉刚看到,改了地址以后仍然会有报错,而且embedding_path在哪里呢?

qinghew commented 1 month ago

Our models are https://github.com/qinghew/CharacterFactory/tree/main/training_weight. please check that embedding_path loads the right path.

qinghew commented 1 month ago

you could also check our demo, and the code is https://huggingface.co/spaces/DecoderWQH666/CharacterFactory/blob/main/app.py.