Kilvoctu / aiyabot

A neat Discord bot for AUTOMATIC1111's Web UI
GNU General Public License v2.0
309 stars 76 forks source link

Error Discord Bot #191

Closed demasakbar closed 1 year ago

demasakbar commented 1 year ago

I have error message like this

Using outputs directory: outputs
Traceback (most recent call last):
  File "D:\Path\Bot\Discord-Bot\aiyabot\venv\lib\site-packages\transformers\modeling_utils.py", line 463, in load_state_dict
    return torch.load(checkpoint_file, map_location="cpu")
  File "D:\Path\Bot\Discord-Bot\aiyabot\venv\lib\site-packages\torch\serialization.py", line 797, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "D:\Path\Bot\Discord-Bot\aiyabot\venv\lib\site-packages\torch\serialization.py", line 283, in __init__
    super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Path\Bot\Discord-Bot\\aiyabot\venv\lib\site-packages\transformers\modeling_utils.py", line 467, in load_state_dict
    if f.read(7) == "version":
  File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 1599: character maps to <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Path\Bot\Discord-Bot\\aiyabot\venv\lib\site-packages\discord\cog.py", line 786, in _load_from_module_spec
    setup(self)
  File "D:\Path\Bot\Discord-Bot\\aiyabot\core\generatecog.py", line 76, in setup
    bot.add_cog(GenerateCog(bot))
  File "D:\Path\Bot\Discord-Bot\\aiyabot\core\generatecog.py", line 20, in __init__
    model = GPT2LMHeadModel.from_pretrained(self.model_path, pad_token_id=tokenizer.eos_token_id)
  File "D:\Path\Bot\Discord-Bot\\aiyabot\venv\lib\site-packages\transformers\modeling_utils.py", line 2604, in from_pretrained
    state_dict = load_state_dict(resolved_archive_file)
  File "D:\Path\Bot\Discord-Bot\\aiyabot\venv\lib\site-packages\transformers\modeling_utils.py", line 479, in load_state_dict
    raise OSError(
OSError: Unable to load weights from pytorch checkpoint file for 'core/MagicPrompt-SD/pytorch_model.bin' at 'core/MagicPrompt-SD/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Path\Bot\Discord-Bot\\aiyabot\aiya.py", line 29, in <module>
    self.load_extension('core.generatecog')
  File "D:\Path\Bot\Discord-Bot\\aiyabot\venv\lib\site-packages\discord\cog.py", line 910, in load_extension
    self._load_from_module_spec(spec, name)
  File "D:\Path\Bot\Discord-Bot\\aiyabot\venv\lib\site-packages\discord\cog.py", line 791, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'core.generatecog' raised an error: OSError: Unable to load weights from pytorch checkpoint file for 'core/MagicPrompt-SD/pytorch_model.bin' at 'core/MagicPrompt-SD/pytorch_model.bin'. If you triedto load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
Kilvoctu commented 1 year ago

Heya, what environment are you running the aiyabot on?

Kilvoctu commented 1 year ago

Closing this issue due to no response.

Ahtlon commented 10 months ago

I've had the same problem and in my case it was caused by the pytorch_model.bin being corrupted or something.

$ shasum core/MagicPrompt-SD/pytorch_model.bin
c11010a918a2ec2ab7029e4d16db044f6b205662  core/MagicPrompt-SD/pytorch_model.bin 

But it should be

$ shasum core/MagicPrompt-SD/pytorch_model.bin 
193180595d73e5463a17cdea187954f0f92860c6  core/MagicPrompt-SD/pytorch_model.bin

Problem was solved by deleting and re-downloading the file.