Method: TensorFlow::Keras::Preprocessing::Image.load_img

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

.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