Image training error

(Rinki Nag) #1

AttributeError: ‘PngStream’ object has no attribute ‘chunk_cmOD’

Here I am getting this error when I train my model not getting why this error is caused


Might be related to PIL/Pillow as I’ve seen similar error messages for other missing attributes.
Which PIL version are you using? If it’s an older one, could you try to update?


I’m not sure, as I haven’t seen the chunk_cmOD attribute error yet and can’t find anything about it.
Did the update fix this issue?

(Rinki Nag) #5

Does this happen due to batch size issues as I have two classless one has 8k images and other has 23k images

OR is images are corrupt


I don’t think it is related to your batch size, since each sample is loaded independently in your Dataset.__getitem__ method.
Your image might be corrupt.
You could try to find this image using a simple loop over your Dataset:

dataset = MyDataset()
for idx, (data, target) in enumerate(dataset):

The corrupt file should be at idx+1, so that you could check the file name using this index.

(Rinki Nag) #7

Hey I have used
train_data = datasets.ImageFolder(’/home/ubuntu/train’,transform=transform)
to read image folder
how can I use your code I am not bale to can you please help


You would just have to use train_data instead of dataset.
Once you run into the error, you can get the image path using train_data.imgs[idx+1].

(Rinki Nag) #9

After running this
for idx, (data, target) in enumerate(train_data):
this stops after 653 idx and the error comes again
so the image on 1st is corupt??

AttributeError: ‘PngStream’ object has no attribute ‘chunk_cmOD’


The image at index 654 is probably corrupt.
Could you check the path using print(train_data.imgs[654]) and see, if the image can be displayed using your default image viewer?

(Rinki Nag) #11

Yes I am able to display the images


Alright, could you try to save it as a new file and replace the old one?
Maybe something broke during saving/downloading this particular file.

(Rinki Nag) #13

Thanks a lot @ [ptrblck] it worked like wonder :slight_smile: