Skip to content

Update image conversion and reshaping for MNIST - #315

Open
NikJur wants to merge 1 commit into
ccpem:developfrom
NikJur:patch-3
Open

NikJur wants to merge 1 commit into
ccpem:developfrom
NikJur:patch-3

Conversation

@NikJur

@NikJur NikJur commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
  • previously failed because MNIST stored as flattened 784-element vector, but aVAE expected 28x28 format

Change np.array to np.asarray for image conversion and add reshaping logic for flattened MNIST images.

Change np.array to np.asarray for image conversion and add reshaping logic for flattened MNIST images.
Copilot AI review requested due to automatic review settings July 30, 2026 10:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.array to np.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.

Comment thread tutorials/mnist_saver.py
Comment on lines 116 to +120
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NikJur are you still working on this PR? note the fail above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I'll take a proper look

@NikJur
NikJur requested a balanced review from Copilot September 17, 2026 06:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

3 participants