feat(detector): add CUDA support for ONNX face detection
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use iced::{
|
||||
Alignment, Element, Length, Task, Theme,
|
||||
Alignment, Element, Length, Settings, Task, Theme,
|
||||
widget::{
|
||||
Space, button, column, container, image, pick_list, progress_bar, row, scrollable, slider,
|
||||
text,
|
||||
@@ -57,9 +57,13 @@ pub enum Tab {
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum ExecutorType {
|
||||
MnnCpu,
|
||||
#[cfg(feature = "mnn-metal")]
|
||||
MnnMetal,
|
||||
#[cfg(feature = "mnn-coreml")]
|
||||
MnnCoreML,
|
||||
OnnxCpu,
|
||||
#[cfg(feature = "ort-cuda")]
|
||||
OrtCuda,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -129,7 +133,10 @@ impl Default for FaceDetectorApp {
|
||||
output_path: None,
|
||||
threshold: 0.8,
|
||||
nms_threshold: 0.3,
|
||||
#[cfg(not(any(feature = "mnn-metal", feature = "ort-cuda")))]
|
||||
executor_type: ExecutorType::MnnCpu,
|
||||
#[cfg(feature = "ort-cuda")]
|
||||
executor_type: ExecutorType::OrtCuda,
|
||||
is_processing: false,
|
||||
progress: 0.0,
|
||||
status_message: "Ready".to_string(),
|
||||
@@ -939,12 +946,17 @@ impl FaceDetectorApp {
|
||||
}
|
||||
|
||||
fn settings_view(&self) -> Element<'_, Message> {
|
||||
let executor_options = vec![
|
||||
ExecutorType::MnnCpu,
|
||||
ExecutorType::MnnMetal,
|
||||
ExecutorType::MnnCoreML,
|
||||
ExecutorType::OnnxCpu,
|
||||
];
|
||||
#[allow(unused_mut)]
|
||||
let mut executor_options = vec![ExecutorType::MnnCpu, ExecutorType::OnnxCpu];
|
||||
|
||||
#[cfg(feature = "mnn-metal")]
|
||||
executor_options.push(ExecutorType::MnnMetal);
|
||||
|
||||
#[cfg(feature = "mnn-coreml")]
|
||||
executor_options.push(ExecutorType::MnnCoreML);
|
||||
|
||||
#[cfg(feature = "ort-cuda")]
|
||||
executor_options.push(ExecutorType::OrtCuda);
|
||||
|
||||
container(
|
||||
column![
|
||||
@@ -990,9 +1002,13 @@ impl std::fmt::Display for ExecutorType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
ExecutorType::MnnCpu => write!(f, "MNN (CPU)"),
|
||||
#[cfg(feature = "mnn-metal")]
|
||||
ExecutorType::MnnMetal => write!(f, "MNN (Metal)"),
|
||||
#[cfg(feature = "mnn-coreml")]
|
||||
ExecutorType::MnnCoreML => write!(f, "MNN (CoreML)"),
|
||||
ExecutorType::OnnxCpu => write!(f, "ONNX (CPU)"),
|
||||
#[cfg(feature = "ort-cuda")]
|
||||
ExecutorType::OrtCuda => write!(f, "ONNX (CUDA)"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1023,10 +1039,15 @@ fn convert_face_rois_to_handles(face_rois: Vec<ndarray::Array3<u8>>) -> Vec<imag
|
||||
}
|
||||
|
||||
pub fn run() -> iced::Result {
|
||||
let settings = Settings {
|
||||
antialiasing: true,
|
||||
..Default::default()
|
||||
};
|
||||
iced::application(
|
||||
"Face Detector",
|
||||
FaceDetectorApp::update,
|
||||
FaceDetectorApp::view,
|
||||
)
|
||||
.settings(settings)
|
||||
.run_with(FaceDetectorApp::new)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user