feat: Added nms

This commit is contained in:
uttarayan21
2025-08-05 15:36:47 +05:30
parent 42ac210bba
commit 06fb0b4487
5 changed files with 85 additions and 25 deletions

View File

@@ -25,25 +25,15 @@ pub fn main() -> Result<()> {
.change_context(errors::Error)
.attach_printable("Failed to convert image to ndarray")?;
let output = model
.detect_faces(array.clone())
.detect_faces(
array.clone(),
FaceDetectionConfig::default().with_threshold(detect.threshold),
)
.change_context(errors::Error)
.attach_printable("Failed to detect faces")?;
// output.print(20);
let faces = output
.postprocess(FaceDetectionConfig::default().with_threshold(detect.threshold))
.change_context(errors::Error)
.attach_printable("Failed to attach context")?;
for bbox in faces.bbox {
for bbox in output.bbox {
tracing::info!("Detected face: {:?}", bbox);
use bounding_box::draw::*;
let bbox = bbox
.denormalize(nalgebra::SVector::<f32, 2>::new(
array.shape()[1] as f32,
array.shape()[0] as f32,
))
.try_cast()
.ok_or(errors::Error)
.attach_printable("Failed to cast f32 to usize")?;
array.draw(bbox, color::palette::css::GREEN_YELLOW.to_rgba8(), 10);
}
let v = array.view();