Conversation
Change np.array to np.asarray for image conversion and add reshaping logic for flattened MNIST images.
There was a problem hiding this comment.
Pull request overview
Updates the MNIST saving pipeline to handle datasets where images are stored as flattened 784-element vectors by converting to NumPy arrays and reshaping into 2D square images before downstream processing.
Changes:
- Switches image conversion from
np.arraytonp.asarray. - Adds logic to detect 1D flattened images and reshape them into a square 2D array (e.g., 28×28), with validation for non-square lengths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| width, height = im.size | ||
| image_name = str(label) + '_' + str(index) + self._image_format | ||
| image = np.array(image) | ||
| image = np.asarray(image) | ||
| # MNIST may be stored as flattened 784-element vectors and need converting into 28x28 | ||
| if image.ndim == 1:0 |
There was a problem hiding this comment.
@NikJur are you still working on this PR? note the fail above
There was a problem hiding this comment.
Worked fine when I ran it, not sure why CoPilot thinks it wouldn't.
But to answer your question, no, I am not working on this. I only noticed that the example demo did not work out of the box due to the vector shape, and this fixed it for me, so I could run the demo.
Hope that helps; feel free to disregard if you already fixed the demo.
There was a problem hiding this comment.
thanks, I'll take a proper look
Change np.array to np.asarray for image conversion and add reshaping logic for flattened MNIST images.