pub struct BaseRecLabelDecode { /* private fields */ }Expand description
A base decoder for text recognition that handles character mapping and basic decoding operations.
This struct is responsible for converting model predictions into readable text strings. It maintains a character dictionary for mapping indices to characters and provides methods for decoding text with optional duplicate removal and confidence scoring.
§Fields
reverse- Flag indicating whether to reverse the text outputdict- A mapping from characters to their indices in the character listcharacter- A list of characters in the vocabulary, indexed by their position
Implementations§
Source§impl BaseRecLabelDecode
impl BaseRecLabelDecode
Sourcepub fn from_string_list(
character_list: Option<&[String]>,
use_space_char: bool,
) -> BaseRecLabelDecode
pub fn from_string_list( character_list: Option<&[String]>, use_space_char: bool, ) -> BaseRecLabelDecode
Creates a new BaseRecLabelDecode instance from a list of strings.
§Arguments
character_list- An optional slice of strings containing the character vocabulary. Only the first character of each string is used. If None, a default alphanumeric character set is used.use_space_char- Whether to include a space character in the vocabulary.
§Returns
A new BaseRecLabelDecode instance.
Sourcepub fn decode(
&self,
text_index: &[Vec<usize>],
text_prob: Option<&[Vec<f32>]>,
is_remove_duplicate: bool,
) -> Vec<(String, f32)>
pub fn decode( &self, text_index: &[Vec<usize>], text_prob: Option<&[Vec<f32>]>, is_remove_duplicate: bool, ) -> Vec<(String, f32)>
Decodes model predictions into text strings with confidence scores.
§Arguments
text_index- A slice of vectors containing the predicted character indices.text_prob- An optional slice of vectors containing the prediction probabilities.is_remove_duplicate- Whether to remove consecutive duplicate characters.
§Returns
A vector of tuples, each containing a decoded text string and its confidence score.
Auto Trait Implementations§
impl Freeze for BaseRecLabelDecode
impl RefUnwindSafe for BaseRecLabelDecode
impl Send for BaseRecLabelDecode
impl Sync for BaseRecLabelDecode
impl Unpin for BaseRecLabelDecode
impl UnwindSafe for BaseRecLabelDecode
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
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>
Converts
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>
Converts
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.