backup: broken backup

This commit is contained in:
uttarayan21
2025-08-07 13:30:34 +05:30
parent 8d07b0846c
commit 2c43f657aa
6 changed files with 292 additions and 181 deletions

View File

@@ -77,6 +77,7 @@ impl Default for FaceDetectionConfig {
}
}
#[derive(Debug)]
pub struct FaceDetection {
handle: mnn_sync::SessionHandle,
}

1
src/faceembed.rs Normal file
View File

@@ -0,0 +1 @@
pub mod facenet;

39
src/faceembed/facenet.rs Normal file
View File

@@ -0,0 +1,39 @@
use crate::errors::*;
use ndarray::{Array1, ArrayView3};
use std::path::Path;
#[derive(Debug)]
pub struct EmbeddingGenerator {
handle: mnn_sync::SessionHandle,
}
impl EmbeddingGenerator {
pub fn new(path: impl AsRef<Path>) -> Result<Self> {
let model = std::fs::read(path)
.change_context(Error)
.attach_printable("Failed to read model file")?;
Self::new_from_bytes(&model)
}
pub fn new_from_bytes(model: &[u8]) -> Result<Self> {
tracing::info!("Loading face embedding model from bytes");
let mut model = mnn::Interpreter::from_bytes(model)
.map_err(|e| e.into_inner())
.change_context(Error)
.attach_printable("Failed to load model from bytes")?;
model.set_session_mode(mnn::SessionMode::Release);
let bc = mnn::BackendConfig::default().with_memory_mode(mnn::MemoryMode::High);
let sc = mnn::ScheduleConfig::new()
.with_type(mnn::ForwardType::CPU)
.with_backend_config(bc);
tracing::info!("Creating session handle for face embedding model");
let handle = mnn_sync::SessionHandle::new(model, sc)
.change_context(Error)
.attach_printable("Failed to create session handle")?;
Ok(Self { handle })
}
pub fn embedding(&self, roi: ArrayView3<u8>) -> Result<Array1<u8>> {
todo!()
}
}

View File

@@ -1,4 +1,5 @@
pub mod errors;
pub mod facedet;
pub mod faceembed;
pub mod image;
use errors::*;