feat: Added cli features for mnn and ort

This commit is contained in:
uttarayan21
2025-08-18 15:07:17 +05:30
parent e7c9c38ed7
commit 3aa95a2ef5
7 changed files with 181 additions and 54 deletions

View File

@@ -1,11 +1,10 @@
use crate::errors::*;
use crate::facedet::*;
use crate::ort_ep::*;
use error_stack::ResultExt;
use ndarray_resize::NdFir;
use ort::{
execution_providers::{
CPUExecutionProvider, CoreMLExecutionProvider, ExecutionProviderDispatch,
},
execution_providers::{CPUExecutionProvider, ExecutionProviderDispatch},
session::{Session, builder::GraphOptimizationLevel},
value::Tensor,
};
@@ -33,18 +32,11 @@ impl FaceDetectionBuilder {
})
}
pub fn with_execution_providers(mut self, providers: Vec<String>) -> Self {
pub fn with_execution_providers(mut self, providers: impl AsRef<[ExecutionProvider]>) -> Self {
let execution_providers: Vec<ExecutionProviderDispatch> = providers
.into_iter()
.filter_map(|provider| match provider.as_str() {
"cpu" | "CPU" => Some(CPUExecutionProvider::default().build()),
#[cfg(target_os = "macos")]
"coreml" | "CoreML" => Some(CoreMLExecutionProvider::default().build()),
_ => {
tracing::warn!("Unknown execution provider: {}", provider);
None
}
})
.as_ref()
.iter()
.filter_map(|provider| provider.to_dispatch())
.collect();
if !execution_providers.is_empty() {