pub struct Decoder {
pub iou_threshold: f32,
pub score_threshold: f32,
pub nms: Option<Nms>,
/* private fields */
}Fields§
§iou_threshold: f32§score_threshold: f32§nms: Option<Nms>NMS mode: Some(mode) applies NMS, None bypasses NMS (for end-to-end models)
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn model_type(&self) -> &ModelType
pub fn model_type(&self) -> &ModelType
This function returns the parsed model type of the decoder.
§Examples
let decoder = DecoderBuilder::default()
.with_config_yaml_str(config_yaml)
.build()?;
assert!(matches!(
decoder.model_type(),
ModelType::ModelPackDetSplit { .. }
));Sourcepub fn normalized_boxes(&self) -> Option<bool>
pub fn normalized_boxes(&self) -> Option<bool>
Returns the box coordinate format if known from the model config.
Some(true): Boxes are in normalized [0,1] coordinatesSome(false): Boxes are in pixel coordinates relative to model inputNone: Unknown, caller must infer (e.g., check if any coordinate > 1.0)
This is determined by the model config’s normalized field, not the NMS
mode. When coordinates are in pixels or unknown, the caller may need
to normalize using the model input dimensions.
§Examples
let decoder = DecoderBuilder::default()
.with_config_yaml_str(config_yaml)
.build()?;
// Config doesn't specify normalized, so it's None
assert!(decoder.normalized_boxes().is_none());Sourcepub fn decode(
&self,
outputs: &[&TensorDyn],
output_boxes: &mut Vec<DetectBox>,
output_masks: &mut Vec<Segmentation>,
) -> Result<(), DecoderError>
pub fn decode( &self, outputs: &[&TensorDyn], output_boxes: &mut Vec<DetectBox>, output_masks: &mut Vec<Segmentation>, ) -> Result<(), DecoderError>
Decode model outputs into detection boxes and segmentation masks.
This is the primary decode API. Accepts TensorDyn outputs directly
from model inference. Automatically dispatches to quantized or float
paths based on the tensor dtype.
§Arguments
outputs- Tensor outputs from model inferenceoutput_boxes- Destination for decoded detection boxes (cleared first)output_masks- Destination for decoded segmentation masks (cleared first)
§Errors
Returns DecoderError if tensor mapping fails, dtypes are unsupported,
or the outputs don’t match the decoder’s model configuration.
Sourcepub fn decode_proto(
&self,
outputs: &[&TensorDyn],
output_boxes: &mut Vec<DetectBox>,
) -> Result<Option<ProtoData>, DecoderError>
pub fn decode_proto( &self, outputs: &[&TensorDyn], output_boxes: &mut Vec<DetectBox>, ) -> Result<Option<ProtoData>, DecoderError>
Decode model outputs into detection boxes, returning raw proto data for segmentation models instead of materialized masks.
Accepts TensorDyn outputs directly from model inference.
Returns Ok(None) for detection-only and ModelPack models.
Returns Ok(Some(ProtoData)) for YOLO segmentation models.
§Arguments
outputs- Tensor outputs from model inferenceoutput_boxes- Destination for decoded detection boxes (cleared first)
§Errors
Returns DecoderError if tensor mapping fails, dtypes are unsupported,
or the outputs don’t match the decoder’s model configuration.
Trait Implementations§
impl StructuralPartialEq for Decoder
Auto Trait Implementations§
impl Freeze for Decoder
impl RefUnwindSafe for Decoder
impl Send for Decoder
impl Sync for Decoder
impl Unpin for Decoder
impl UnsafeUnpin for Decoder
impl UnwindSafe for Decoder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more