Module: TensorFlow::Keras::Preprocessing::Image

Defined in:
lib/tensorflow/keras/preprocessing/image.rb

Class Method Summary collapse

Class Method Details

.img_to_array(img) ⇒ Object



15
16
17
# 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) ⇒ Object



6
7
8
9
10
11
12
13
# 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