pub struct LayoutDetectionConfig {
pub score_threshold: f32,
pub max_elements: usize,
pub class_thresholds: Option<HashMap<String, f32>>,
pub class_merge_modes: Option<HashMap<String, MergeBboxMode>>,
pub layout_nms: bool,
pub nms_threshold: f32,
pub layout_unclip_ratio: Option<UnclipRatio>,
}Expand description
Configuration for layout detection task.
Fields§
§score_threshold: f32Default score threshold for detection (default: 0.5)
max_elements: usizeMaximum number of layout elements (default: 100)
class_thresholds: Option<HashMap<String, f32>>Per-class score thresholds (overrides score_threshold for specific classes) PP-StructureV3 defaults:
- paragraph_title: 0.3
- formula: 0.3
- text: 0.4
- seal: 0.45
- others: 0.5
class_merge_modes: Option<HashMap<String, MergeBboxMode>>Per-class bounding box merge modes
layout_nms: boolEnable NMS for layout detection (default: true)
nms_threshold: f32NMS threshold (default: 0.5)
layout_unclip_ratio: Option<UnclipRatio>Unclip ratio for expanding/shrinking bounding boxes (PP-StructureV3) Default: [1.0, 1.0] (no change)
Implementations§
Source§impl LayoutDetectionConfig
impl LayoutDetectionConfig
Sourcepub fn with_pp_structurev3_thresholds() -> LayoutDetectionConfig
pub fn with_pp_structurev3_thresholds() -> LayoutDetectionConfig
Creates a config with PP-StructureV3 default class thresholds.
PP-StructureV3 uses different thresholds for different element types:
- paragraph_title: 0.3
- formula: 0.3
- text: 0.4
- seal: 0.45
- others: 0.5 (default)
Sourcepub fn with_pp_doclayoutv2_defaults() -> LayoutDetectionConfig
pub fn with_pp_doclayoutv2_defaults() -> LayoutDetectionConfig
Creates a config with PP-DocLayoutV2 default thresholds and merge modes.
These defaults are aligned with OpenOCR/OpenDoc’s pipeline config:
OpenOCR/configs/rec/unirec/opendoc_pipeline.yml.
Notes:
- The postprocessor applies
score_thresholdbefore per-class thresholds, so we set it to the minimum per-class threshold (0.4) to avoid dropping valid candidates early. class_merge_modesis populated for all labels so merge behavior is deterministic.
Sourcepub fn with_pp_doclayoutv3_defaults() -> LayoutDetectionConfig
pub fn with_pp_doclayoutv3_defaults() -> LayoutDetectionConfig
Creates a config with PP-DocLayoutV3 defaults (0.3 threshold + PP-DocLayout merge modes).
PP-DocLayoutV3 keeps the same label set as PP-DocLayoutV2 but uses a lower global threshold in the reference pipeline.
Sourcepub fn with_pp_structurev3_defaults() -> LayoutDetectionConfig
pub fn with_pp_structurev3_defaults() -> LayoutDetectionConfig
Creates a config with PP-StructureV3 default thresholds, merge modes, and unclip ratio.
Merge modes follow standard configuration:
- “large”: paragraph_title, image, formula, chart
- “union”: all other PP-DocLayout_plus-L classes
Sourcepub fn get_class_threshold(&self, class_name: &str) -> f32
pub fn get_class_threshold(&self, class_name: &str) -> f32
Gets the threshold for a specific class.
Returns the class-specific threshold if configured, otherwise the default threshold.
Sourcepub fn get_class_merge_mode(&self, class_name: &str) -> MergeBboxMode
pub fn get_class_merge_mode(&self, class_name: &str) -> MergeBboxMode
Gets the merge mode for a specific class.
Returns the class-specific merge mode if configured, otherwise Large (default).
Trait Implementations§
Source§impl Clone for LayoutDetectionConfig
impl Clone for LayoutDetectionConfig
Source§fn clone(&self) -> LayoutDetectionConfig
fn clone(&self) -> LayoutDetectionConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConfigValidator for LayoutDetectionConfig
impl ConfigValidator for LayoutDetectionConfig
Source§fn get_defaults() -> LayoutDetectionConfigwhere
LayoutDetectionConfig: Sized,
fn get_defaults() -> LayoutDetectionConfigwhere
LayoutDetectionConfig: Sized,
Source§fn validate_batch_size(&self, batch_size: usize) -> Result<(), ConfigError>
fn validate_batch_size(&self, batch_size: usize) -> Result<(), ConfigError>
Source§fn validate_batch_size_with_limits(
&self,
batch_size: usize,
max_batch_size: usize,
) -> Result<(), ConfigError>
fn validate_batch_size_with_limits( &self, batch_size: usize, max_batch_size: usize, ) -> Result<(), ConfigError>
Source§fn validate_model_path(&self, path: &Path) -> Result<(), ConfigError>
fn validate_model_path(&self, path: &Path) -> Result<(), ConfigError>
Source§fn validate_image_dimensions(
&self,
width: u32,
height: u32,
) -> Result<(), ConfigError>
fn validate_image_dimensions( &self, width: u32, height: u32, ) -> Result<(), ConfigError>
Source§fn validate_confidence_threshold(
&self,
threshold: f32,
) -> Result<(), ConfigError>
fn validate_confidence_threshold( &self, threshold: f32, ) -> Result<(), ConfigError>
Source§fn validate_memory_limit(&self, limit_mb: usize) -> Result<(), ConfigError>
fn validate_memory_limit(&self, limit_mb: usize) -> Result<(), ConfigError>
Source§fn validate_thread_count(&self, thread_count: usize) -> Result<(), ConfigError>
fn validate_thread_count(&self, thread_count: usize) -> Result<(), ConfigError>
Source§fn validate_f32_range(
&self,
value: f32,
min: f32,
max: f32,
field_name: &str,
) -> Result<(), ConfigError>
fn validate_f32_range( &self, value: f32, min: f32, max: f32, field_name: &str, ) -> Result<(), ConfigError>
Source§fn validate_positive_f32(
&self,
value: f32,
field_name: &str,
) -> Result<(), ConfigError>
fn validate_positive_f32( &self, value: f32, field_name: &str, ) -> Result<(), ConfigError>
Source§fn validate_positive_usize(
&self,
value: usize,
field_name: &str,
) -> Result<(), ConfigError>
fn validate_positive_usize( &self, value: usize, field_name: &str, ) -> Result<(), ConfigError>
Source§impl Debug for LayoutDetectionConfig
impl Debug for LayoutDetectionConfig
Source§impl Default for LayoutDetectionConfig
impl Default for LayoutDetectionConfig
Source§fn default() -> LayoutDetectionConfig
fn default() -> LayoutDetectionConfig
Source§impl<'de> Deserialize<'de> for LayoutDetectionConfig
impl<'de> Deserialize<'de> for LayoutDetectionConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LayoutDetectionConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LayoutDetectionConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for LayoutDetectionConfig
impl Serialize for LayoutDetectionConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for LayoutDetectionConfig
impl RefUnwindSafe for LayoutDetectionConfig
impl Send for LayoutDetectionConfig
impl Sync for LayoutDetectionConfig
impl Unpin for LayoutDetectionConfig
impl UnsafeUnpin for LayoutDetectionConfig
impl UnwindSafe for LayoutDetectionConfig
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> ConfigDefaults for Twhere
T: ConfigValidator,
impl<T> ConfigDefaults for Twhere
T: ConfigValidator,
Source§impl<T> ConfigValidatorExt for Twhere
T: ConfigValidator,
impl<T> ConfigValidatorExt for Twhere
T: ConfigValidator,
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<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().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.