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



862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
# File 'lib/informers/pipelines.rb', line 862

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