Sha256: 4eee263c4cfad16c2fb9632732ecc12a3511f04459a3fde6333a65e771d06d98

Contents?: true

Size: 638 Bytes

Versions: 87

Compression:

Stored size: 638 Bytes

Contents

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

    def predict(input_feed, output_names: nil, **run_options)
      predictions = @session.run(output_names, input_feed, **run_options)
      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

    def metadata
      @session.modelmeta
    end
  end
end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
onnxruntime-0.9.3-x86_64-linux lib/onnxruntime/model.rb
onnxruntime-0.9.3-x86_64-darwin lib/onnxruntime/model.rb
onnxruntime-0.9.3-x64-mingw lib/onnxruntime/model.rb
onnxruntime-0.9.3-arm64-darwin lib/onnxruntime/model.rb
onnxruntime-0.9.3-aarch64-linux lib/onnxruntime/model.rb
onnxruntime-0.9.3 lib/onnxruntime/model.rb
onnxruntime-0.9.2-x86_64-linux lib/onnxruntime/model.rb
onnxruntime-0.9.2-x86_64-darwin lib/onnxruntime/model.rb
onnxruntime-0.9.2-x64-mingw lib/onnxruntime/model.rb
onnxruntime-0.9.2-arm64-darwin lib/onnxruntime/model.rb
onnxruntime-0.9.2-aarch64-linux lib/onnxruntime/model.rb
onnxruntime-0.9.2 lib/onnxruntime/model.rb
onnxruntime-0.9.0-x86_64-linux lib/onnxruntime/model.rb
onnxruntime-0.9.0-x86_64-darwin lib/onnxruntime/model.rb
onnxruntime-0.9.0-x64-mingw lib/onnxruntime/model.rb
onnxruntime-0.9.0-arm64-darwin lib/onnxruntime/model.rb
onnxruntime-0.9.0-aarch64-linux lib/onnxruntime/model.rb
onnxruntime-0.9.0 lib/onnxruntime/model.rb
onnxruntime-0.8.0-x86_64-linux lib/onnxruntime/model.rb
onnxruntime-0.8.0-x86_64-darwin lib/onnxruntime/model.rb