pbaylies / stylegan-encoder

StyleGAN Encoder - converts real images to latent space
Other
740 stars 182 forks source link

assert img.shape == self.shape Assertion Error #62

Closed augustfr closed 3 years ago

augustfr commented 3 years ago

I made a dataset of about 10k images. While running the dataset_tool, it added 5044 images and then gave me this error.

File "dataset_tool.py", line 78, in add_image assert img.shape == self.shape AssertionError

Any ideas on what happened?

pbaylies commented 3 years ago

It sounds like the 5045th image wasn't the same shape (dimension or channel) as the other 5044 images...

augustfr commented 3 years ago

Somehow it isn't that since I ran the whole data set through a script that resizes them to 1024x1024 and removes any grayscale images. That's why I'm unsure why this would happen since they're all the same size.

I also just tried deleting the 5044th 5045th and 5046th image just to be safe and now the error is saying its added 5041 images before the same error happens

augustfr commented 3 years ago

Just ran a script to print the image shape and it says that all 10k images are (1024,1024,3). Any ideas on why I get that assertion error still?

pbaylies commented 3 years ago

Ugh. Sounds like your dataset is haunted. Make sure it's not something ridiculous, like running out of space, or a file size limit? I'd add a bit of logging to the script too, even if you're just printing out the shape every time. I'll also mention that if you don't need original StyleGAN, there are newer repos for StyleGAN2, that may even have some updates to the dataset tool script.

augustfr commented 3 years ago

Figured it out for anyone wondering. The issue was that 3 of my files in the dataset were CMYK (4 channel). Those 3 seemed to slip by when I checked the shape earlier on.

pbaylies commented 3 years ago

Glad you figured it out!