Class: OnnxRuntime::Model
- Inherits:
-
Object
- Object
- OnnxRuntime::Model
- Defined in:
- lib/onnxruntime/model.rb
Instance Method Summary collapse
-
#initialize(path_or_bytes, **session_options) ⇒ Model
constructor
A new instance of Model.
- #inputs ⇒ Object
- #metadata ⇒ Object
- #outputs ⇒ Object
- #predict(input_feed, output_names: nil, **run_options) ⇒ Object
Constructor Details
#initialize(path_or_bytes, **session_options) ⇒ Model
Returns a new instance of Model.
3 4 5 |
# File 'lib/onnxruntime/model.rb', line 3 def initialize(path_or_bytes, **) @session = InferenceSession.new(path_or_bytes, **) end |
Instance Method Details
#inputs ⇒ Object
18 19 20 |
# File 'lib/onnxruntime/model.rb', line 18 def inputs @session.inputs end |
#metadata ⇒ Object
26 27 28 |
# File 'lib/onnxruntime/model.rb', line 26 def @session. end |
#outputs ⇒ Object
22 23 24 |
# File 'lib/onnxruntime/model.rb', line 22 def outputs @session.outputs end |
#predict(input_feed, output_names: nil, **run_options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/onnxruntime/model.rb', line 7 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 |