Sha256: ef0268b47a6ba33ea4a9b775fc3b090fd8fe6c8026f4f57c06c08462f6dac2ff

Contents?: true

Size: 519 Bytes

Versions: 5

Compression:

Stored size: 519 Bytes

Contents

module OnnxRuntime
  class Model
    def initialize(path_or_bytes)
      @session = InferenceSession.new(path_or_bytes)
    end

    def predict(input_feed, output_names: nil)
      predictions = @session.run(output_names, input_feed)
      output_names ||= outputs.map { |o| o[:name] }

      result = {}
      output_names.zip(predictions).each do |k, v|
        result[k.to_s] = v
      end
      result
    end

    def inputs
      @session.inputs
    end

    def outputs
      @session.outputs
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
onnxruntime-0.2.1 lib/onnxruntime/model.rb
onnxruntime-0.2.0 lib/onnxruntime/model.rb
onnxruntime-0.1.2 lib/onnxruntime/model.rb
onnxruntime-0.1.1 lib/onnxruntime/model.rb
onnxruntime-0.1.0 lib/onnxruntime/model.rb