Code Monkey home page Code Monkey logo

Comments (6)

MarcusFra avatar MarcusFra commented on July 30, 2024

Hey, it's an PIL.UnidentifiedImageError – the image cannot be opened and identified.

  1. Are you able to open the image ./train/cat\1004525_cba96ba3c3.jpg on your working station? Is it a real picture/valid file? Edit: The backslash after cat seems a bit weird to me: the images with the cats should be in an own directory called cat, I think it needs to be a slash instead of the backslash.
  2. How have you acquired the image files? Have you used the download.py file or the gdrive link?

from beginners-pytorch-deep-learning.

hero-117 avatar hero-117 commented on July 30, 2024

Hey, it's an PIL.UnidentifiedImageError – the image cannot be opened and identified.

  1. Are you able to open the image ./train/cat\1004525_cba96ba3c3.jpg on your working station? Is it a real picture/valid file? Edit: The backslash after cat seems a bit weird to me: the images with the cats should be in an own directory called cat, I think it needs to be a slash instead of the backslash.
  2. How have you acquired the image files? Have you used the download.py file or the gdrive link?

_
thanks for your help!

I download this image package through G Drive, after your reminder, i check the package on my PC and found '1004525_cba96ba3c3.jpg' has broken, does it means i must use check_image()?

from beginners-pytorch-deep-learning.

MarcusFra avatar MarcusFra commented on July 30, 2024

Yes, please adjust your code for the three respective lines and add , is_valid_file=check_image. The check_image() function is included to avoid these kind of error messages and the broken images not being considered.

For example for the training data use the ImageFolder class as follows (see https://github.com/falloutdurham/beginners-pytorch-deep-learning/blob/master/chapter2/Chapter%202.ipynb):

train_data = torchvision.datasets.ImageFolder(root=train_data_path,
                                              transform=img_transforms,
                                              is_valid_file=check_image)

The same for val_data and test_data.

Is there any reason you deleted it in the code you forked from the gihub repo?

from beginners-pytorch-deep-learning.

MarcusFra avatar MarcusFra commented on July 30, 2024

If you got an FileNotFoundError with the check_image() function please check out #71.

from beginners-pytorch-deep-learning.

hero-117 avatar hero-117 commented on July 30, 2024

Yes, please adjust your code for the three respective lines and add , is_valid_file=check_image. The check_image() function is included to avoid these kind of error messages and the broken images not being considered.

For example for the training data use the ImageFolder class as follows (see https://github.com/falloutdurham/beginners-pytorch-deep-learning/blob/master/chapter2/Chapter%202.ipynb):

train_data = torchvision.datasets.ImageFolder(root=train_data_path,
                                              transform=img_transforms,
                                              is_valid_file=check_image)

The same for val_data and test_data.

Is there any reason you deleted it in the code you forked from the gihub repo?

Thanks for your patient!
The reason I delete 'img_check()' is I noticed the bug in torchvision you mentioned in another issue, it seems that the function is important for both download by Url and GDrive. Or we can update a new image package to GDrive.

from beginners-pytorch-deep-learning.

MarcusFra avatar MarcusFra commented on July 30, 2024

Yes, unfortunately also some GDrive images seem to be affected, but there is no issue at all as long it's possible to include the check_image() function.

I think it's best to downgrade torchvision to 0.10.1 as mentionend in #71 - or you can upgrade to 0.12.0 (released 2 days ago; the bug mentioned in #71 has been fixed in the release - but be aware that the new release has not been tested for this book repo yet).

from beginners-pytorch-deep-learning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.