lucidrains / DALLE-pytorch

Implementation / replication of DALL-E, OpenAI's Text to Image Transformer, in Pytorch
MIT License
5.57k stars 642 forks source link

Fix Tokenizer Decoding #410

Closed tillfalko closed 2 years ago

tillfalko commented 2 years ago

Right now, in the multiple decode() functions, pad_tokens is by default initialized to {} i.e. a dict. This causes ignore_ids = pad_tokens.union({0}) to raise an AttributeError.

  File "/content/DALLE-pytorch/train_dalle.py", line 642, in <module>
    decoded_text = tokenizer.decode(token_list)
  File "/content/DALLE-pytorch/dalle_pytorch/tokenizer.py", line 245, in decode
    return self.tokenizer.decode(tokens, ignore_ids = pad_tokens.union({0}))
AttributeError: 'dict' object has no attribute 'union'

With this PR pad_tokens is initialized to set() instead.

lucidrains commented 2 years ago

oh my, thank you! 🙏