Sha256: ca4b2ac05df8a8691d16e76861a94d523ebcb7271479ed6d1b4a0015aa498213

Contents?: true

Size: 540 Bytes

Versions: 1

Compression:

Stored size: 540 Bytes

Contents

module TensorFlow
  module Keras
    module Preprocessing
      module Image
        class << self
          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

          def img_to_array(img)
            Numo::SFloat.cast(img.get_pixels)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tensorflow-0.2.0 lib/tensorflow/keras/preprocessing/image.rb