Closed andrew-alm closed 2 years ago
Hi! I believe it's an issue with the files in the data directory you use. I suggest printing the sizes of self.shape and img.shape, as well as the image filename it uses when throwing the exception. And then you can track down the problematic image.
The image files are sorted using python sort() so if they are e.g. 1.png, 2.png, ..., 11.png it's going to sort them into: 1.png, 11.png, 2.png, and so it might be the case that you didn't remove the problematic image. Also note that when you do find the image that isn't good you may just need to crop/pad/resize it to the right shape rather than deleting it. Good luck and let me know how it goes!
The sorting was throwing me off. I modified the assert statement, and I guess the directory contains different sized images. I had been creating my own TF Data datasets mapping a resize function which made it so I wasn't aware.
Thanks for the help, this can be closed.
When using
prepare_data.py
to create a custom dataset for training, I keep encountering an AssertionError. I've looked at the code, but I'm not sure what exactly is causing this shape mismatch. I've also tried different environments to hopefully rule out anything related to that aspect.Environments:
Data:
Command:
python prepare_data.py --task covidx --images-dir /data/2A_images --format png --ratio 0.7 --shards-num 20 --max-images 194922
Error:
The process always fails at exactly 15340. I've removed image 15340 (repeatedly down the line), but the error keeps happening.