pub struct DBPostProcess {
pub thresh: f32,
pub box_thresh: f32,
pub max_candidates: usize,
pub unclip_ratio: f32,
pub min_size: f32,
pub score_mode: ScoreMode,
pub box_type: BoxType,
pub use_dilation: bool,
}Expand description
Post-processor for DB (Differentiable Binarization) text detection models.
Fields§
§thresh: f32Default threshold for binarizing the prediction map (default: 0.3).
box_thresh: f32Default threshold for filtering bounding boxes based on their score (default: 0.6).
max_candidates: usizeMaximum number of candidate bounding boxes to consider (default: 1000).
unclip_ratio: f32Default ratio for unclipping (expanding) bounding boxes (default: 1.5).
min_size: f32Minimum side length for detected bounding boxes.
score_mode: ScoreModeMethod for calculating the score of a bounding box.
box_type: BoxTypeType of bounding box to generate (quadrilateral or polygon).
use_dilation: boolWhether to apply dilation to the segmentation mask before contour detection.
Implementations§
Source§impl DBPostProcess
impl DBPostProcess
Sourcepub fn box_score_fast(
&self,
pred: &ArrayBase<ViewRepr<&f32>, Dim<[usize; 2]>>,
bbox: &BoundingBox,
) -> f32
pub fn box_score_fast( &self, pred: &ArrayBase<ViewRepr<&f32>, Dim<[usize; 2]>>, bbox: &BoundingBox, ) -> f32
Calculates the score of a bounding box using a fast approximation method.
Source§impl DBPostProcess
impl DBPostProcess
Sourcepub fn new(
thresh: Option<f32>,
box_thresh: Option<f32>,
max_candidates: Option<usize>,
unclip_ratio: Option<f32>,
use_dilation: Option<bool>,
score_mode: Option<ScoreMode>,
box_type: Option<BoxType>,
) -> DBPostProcess
pub fn new( thresh: Option<f32>, box_thresh: Option<f32>, max_candidates: Option<usize>, unclip_ratio: Option<f32>, use_dilation: Option<bool>, score_mode: Option<ScoreMode>, box_type: Option<BoxType>, ) -> DBPostProcess
Creates a new DBPostProcess instance with optional overrides.
Sourcepub fn apply(
&self,
preds: &ArrayBase<OwnedRepr<f32>, Dim<[usize; 4]>>,
img_shapes: Vec<ImageScaleInfo>,
config: Option<&DBPostProcessConfig>,
) -> (Vec<Vec<BoundingBox>>, Vec<Vec<f32>>)
pub fn apply( &self, preds: &ArrayBase<OwnedRepr<f32>, Dim<[usize; 4]>>, img_shapes: Vec<ImageScaleInfo>, config: Option<&DBPostProcessConfig>, ) -> (Vec<Vec<BoundingBox>>, Vec<Vec<f32>>)
Applies post-processing to a batch of prediction maps.
§Arguments
preds- Model predictions (batch of heatmaps)img_shapes- Original image dimensions for each image in batchconfig- Runtime configuration for thresholds and ratios. IfNone, uses the default values stored in this processor.
§Returns
Tuple of (bounding_boxes, scores) for each image in batch
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DBPostProcess
impl RefUnwindSafe for DBPostProcess
impl Send for DBPostProcess
impl Sync for DBPostProcess
impl Unpin for DBPostProcess
impl UnwindSafe for DBPostProcess
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.