Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【第1章】【1-3_transfer_learning.ipynb】にてエラーが発生します(UnboundLocalError: local variable 'photoshop' referenced before assignment) #9

Open
YutaroOgawa opened this issue Jul 28, 2019 · 1 comment
Labels
question Further information is requested 誤植

Comments

@YutaroOgawa
Copy link
Owner

対象ファイル:1-3_transfer_learning.ipynb

学習の途中でエラーが発生します。

どう対応すれば良いでしょうか?

UnboundLocalError: local variable 'photoshop' referenced before assignment

  File "train.py", line 416, in <module>
    trained_net = train_model(net, dataloaders_dict, criterion, optimizer, num_epochs=num_epochs)
  File "train.py", line 368, in train_model
    for inputs, labels in tqdm(dataloaders_dict[phase]):
  File "/anaconda/envs/py36/lib/python3.6/site-packages/tqdm/_tqdm.py", line 1005, in __iter__
    for obj in iterable:
  File "/anaconda/envs/py36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 560, in __next__
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/anaconda/envs/py36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 560, in <listcomp>
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "train.py", line 245, in __getitem__
    img = Image.open(img_path)  # [高さ][幅][色RGB]
  File "/anaconda/envs/py36/lib/python3.6/site-packages/PIL/Image.py", line 2690, in open
    im = _open_core(fp, filename, prefix)
  File "/anaconda/envs/py36/lib/python3.6/site-packages/PIL/Image.py", line 2676, in _open_core
    im = factory(fp, filename)
  File "/anaconda/envs/py36/lib/python3.6/site-packages/PIL/JpegImagePlugin.py", line 783, in jpeg_factory
    im = JpegImageFile(fp, filename)
  File "/anaconda/envs/py36/lib/python3.6/site-packages/PIL/ImageFile.py", line 103, in __init__
    self._open()
  File "/anaconda/envs/py36/lib/python3.6/site-packages/PIL/JpegImagePlugin.py", line 373, in _open
    handler(self, i)
  File "/anaconda/envs/py36/lib/python3.6/site-packages/PIL/JpegImagePlugin.py", line 139, in APP
    self.info["photoshop"] = photoshop
UnboundLocalError: local variable 'photoshop' referenced before assignment
@YutaroOgawa YutaroOgawa added question Further information is requested 誤植 labels Jul 28, 2019
@YutaroOgawa
Copy link
Owner Author

ありがとうございます。

このエラーは、PIL(pillow)のバージョンが6以上の場合に発生するようです。

こちらでも挙げられています。
UnboundLocalError in PIL/JpegImagePlugin.py

対応策ですが、pillowのバージョンを下げてください。

コンソール画面などで、

pip install pillow==5.4.1

を実行し、pillowのバージョンを6から5系に下げます。

どうぞよろしくお願い致します。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested 誤植
Projects
None yet
Development

No branches or pull requests

1 participant