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
13 14 15 |
# File 'lib/onnxruntime/model.rb', line 13 def inputs @session.inputs end |
#metadata ⇒ Object
21 22 23 |
# File 'lib/onnxruntime/model.rb', line 21 def @session. end |
#outputs ⇒ Object
17 18 19 |
# File 'lib/onnxruntime/model.rb', line 17 def outputs @session.outputs end |
#predict(input_feed, output_names: nil, **run_options) ⇒ Object
7 8 9 10 11 |
# 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] } output_names.zip(predictions).to_h { |k, v| [k.to_s, v] } end |