pub struct InsightFace { /* private fields */ }Expand description
InsightFace is a struct which handle the internal pointers to compare two faces and returns the cosine value
Implementations§
Source§impl InsightFace
impl InsightFace
Sourcepub fn new<S: AsRef<str>>(
model: S,
chunk_size: Option<usize>,
) -> Result<Self, Box<dyn Error>>
pub fn new<S: AsRef<str>>( model: S, chunk_size: Option<usize>, ) -> Result<Self, Box<dyn Error>>
Create a new InsightFace handler. It needs to be only call once as it build a model. Therefore it’s recommended
to use it within an Arc<Mutex<InsightFace>> to ensure thread safety. Chunk size is used in order to split the image data into smaller chunks for processing.
§Arguments
model- Schunk_size- u8
§Examples
use std::sync::Arc;
use std::sync::Mutex;
use baklava::InsightFace;
let insight_face = Arc::new(Mutex::new(InsightFace::new("./Megatron", None).unwrap()));Sourcepub fn prepare_images<S: AsRef<str> + Clone + Send + Sync + Copy>(
&mut self,
sources: &[S],
) -> Result<&mut Self, Box<dyn Error>>
pub fn prepare_images<S: AsRef<str> + Clone + Send + Sync + Copy>( &mut self, sources: &[S], ) -> Result<&mut Self, Box<dyn Error>>
Sourcepub fn prepare_target_image<S: AsRef<str>>(
&mut self,
target_img_path: S,
) -> Result<&mut Self, Box<dyn Error>>
pub fn prepare_target_image<S: AsRef<str>>( &mut self, target_img_path: S, ) -> Result<&mut Self, Box<dyn Error>>
Prepare the target image that will be compared against the sources images
§Arguments
target_img_path- S
Sourcepub fn compare_images(
&self,
methodology: Methodology,
) -> Result<(f32, f64), Box<dyn Error>>
pub fn compare_images( &self, methodology: Methodology, ) -> Result<(f32, f64), Box<dyn Error>>
Compare the images and return the cosine similary which can range from 1 to -1
§Arguments
methodology- Methodology
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for InsightFace
impl !RefUnwindSafe for InsightFace
impl Unpin for InsightFace
impl UnwindSafe for InsightFace
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