pub struct Model { /* private fields */ }Expand description
Represents a loaded ML model
Implementations§
Source§impl Model
impl Model
Sourcepub fn load<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self>
Load a model from an ONNX file
§Example
use ronn_api::Model;
let model = Model::load("model.onnx")?;Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Load a model from bytes
§Example
use ronn_api::Model;
let bytes = std::fs::read("model.onnx")?;
let model = Model::from_bytes(&bytes)?;Sourcepub fn create_session_default(&self) -> Result<InferenceSession>
pub fn create_session_default(&self) -> Result<InferenceSession>
Create an inference session with default options
§Example
use ronn_api::Model;
let model = Model::load("model.onnx")?;
let session = model.create_session_default()?;Sourcepub fn create_session(
&self,
options: SessionOptions,
) -> Result<InferenceSession>
pub fn create_session( &self, options: SessionOptions, ) -> Result<InferenceSession>
Create an inference session with custom options
§Example
use ronn_api::{Model, SessionOptions, OptimizationLevel};
use ronn_providers::ProviderType;
let model = Model::load("model.onnx")?;
let options = SessionOptions::new()
.with_optimization_level(OptimizationLevel::O3)
.with_provider(ProviderType::GPU);
let session = model.create_session(options)?;Sourcepub fn producer_name(&self) -> Option<&str>
pub fn producer_name(&self) -> Option<&str>
Get model metadata
Sourcepub fn ir_version(&self) -> i64
pub fn ir_version(&self) -> i64
Get IR version
Sourcepub fn input_names(&self) -> Vec<&str>
pub fn input_names(&self) -> Vec<&str>
Get input names
Sourcepub fn output_names(&self) -> Vec<&str>
pub fn output_names(&self) -> Vec<&str>
Get output names
Auto Trait Implementations§
impl Freeze for Model
impl !RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl !UnwindSafe for Model
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more