module TensorFlow::Keras::Preprocessing::Image

Public Class Methods

img_to_array(img) click to toggle source
# File lib/tensorflow/keras/preprocessing/image.rb, line 15
def img_to_array(img)
  Numo::SFloat.cast(img.get_pixels)
end
load_img(path, target_size: nil) click to toggle source
# File lib/tensorflow/keras/preprocessing/image.rb, line 6
def load_img(path, target_size: nil)
  img = MiniMagick::Image.open(path)
  if target_size
    # TODO make resize consistent with Python
    img.resize "#{target_size.map(&:to_i).join("x")}!", "-filter", "point"
  end
  img
end