keras-team / keras-preprocessing

Utilities for working with image data, text data, and sequence data.
Other
1.02k stars 444 forks source link

Updated keras_preprocessing image utils #303

Closed novasush closed 4 years ago

novasush commented 4 years ago

Summary

I have made some changes, that can be useful for people working on image processing.

  1. image.load_img() Gave me TypeError for loading bytes image, corrected the function to read an image from the path and BytesIO object.

  2. image.array_to_img() Used to fail on grayscale images because their ndim was less than 3, now added an optional flag is_grayscale to add single channel to grayscale image array with ndim = 2

  3. image.img_to_array() Replaced np.asarray() with np.array(), can be useful with cv2 functions, earlier np.asarray processed images gave different output when used with cv2 functions because array used to be modified. Now a copy of array is processed for use with cv2

    Related Issues

PR Overview

Dref360 commented 4 years ago

I don't think reverting this commit is the right way to fix this issue, could you look into it?