Class: Informers::ImageToImagePipeline

Inherits:
Pipeline
  • Object
show all
Defined in:
lib/informers/pipelines.rb

Instance Method Summary collapse

Methods inherited from Pipeline

#initialize

Constructor Details

This class inherits a constructor from Informers::Pipeline

Instance Method Details

#call(images) ⇒ Object



991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
# File 'lib/informers/pipelines.rb', line 991

def call(images)
  prepared_images = prepare_images(images)
  inputs = @processor.(prepared_images)
  outputs = @model.(inputs)

  to_return = []
  outputs[0].each do |batch|
    # TODO flatten first
    output =
      batch.map do |v|
        v.map do |v2|
          v2.map do |v3|
            (v3.clamp(0, 1) * 255).round
          end
        end
      end
    to_return << Utils::RawImage.from_array(output).image
  end

  to_return.length > 1 ? to_return : to_return[0]
end