5

So I have my images in a numpy array but not in a directory. I have a final numpy array which is a 4d tensor of shape (sample, 48, 48, 1). My goal is to use keras's image data generator to convert them to (sample, 224, 224, 1). Please guide me on how to do it as so far I have seen examples of people using image data generators from the directory where they load actuall images.

I have 4 numpy arrays stored localy train_images.npy, train_labels.npy, test_images.npy and test_labels.npy.

The shape for images in these numpy is (sample, 48, 48, 1) The shape for labels in these numpy is (sample, number of classes) as i have already converted them to keras.utils.np_utils.to_categorical method.

1
  • could you include any code you have already tried? why cant you save your images to a directory? Commented Oct 11, 2019 at 11:05

1 Answer 1

11

For this you should use ImageDataGenerator.flow, which takes numpy arrays directly. This replaces the flow_from_directory call, all other code using the generator should be the same.

Sign up to request clarification or add additional context in comments.

1 Comment

Amazing. Worked like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.