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

Fix a bug that leads to "ValueError: axes don't match array" in dataset_tool.py #111

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lowlypalace
Copy link

@lowlypalace lowlypalace commented Apr 16, 2022

This is a patch to the Issue #110

Here's a fix for dataset_tool.py that fixes ValueError: axes don't match array, images will work one run and not work the next error.

My debugging of the issue was as follows:

  • I first thought that maybe some of the images I scraped were grayscale. To solve this I used imagemagick and tried to run magick identify *.jpg to search for greyscale images to purge from the dataset but the issue still persisted in my case.
  • I tried to mass-edit the colorspace of the images and resolution. This still hasn't fixed the error which I was randomly getting on some of the images.
  • I still can't debug the exact origin of the issue such as a specific colorspace causing dataset_tool.py to crash.

I propose to use PIL to convert the image to RGB in any case. It should be able to work fine if the images are not sRGB, including the case when they are grayscale. It will most likely slows down the dataset preprocessing step a little bit (I haven't run any benchmarks). However, it is convenient if the training data is coming from varied sources, which I believe is the case for my users.

@lowlypalace lowlypalace changed the title Fix a bug that led to "ValueError: axes don't match array" in dataset_tool.py Fix a bug that leads to "ValueError: axes don't match array" in dataset_tool.py Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant