pub struct FormulaRecognizer {
pub decoder_enabled: bool,
/* private fields */
}Expand description
Riconosce formule matematiche in immagini crop → stringa LaTeX.
Fields§
§decoder_enabled: boolAbilita il decoder autoregressive. Default false: quando
disabilitato [recognize] restituisce latex = "" senza eseguire
alcuna inferenza. Impostare a true solo quando si vuole produrre
output LaTeX effettivo (il decoder è costoso: fino a 2560 step).
Implementations§
Source§impl FormulaRecognizer
impl FormulaRecognizer
Sourcepub fn from_paths(
model_path: impl AsRef<Path>,
tokenizer_path: Option<&Path>,
) -> Result<Self, OcrError>
pub fn from_paths( model_path: impl AsRef<Path>, tokenizer_path: Option<&Path>, ) -> Result<Self, OcrError>
Carica il modello ONNX e il tokenizer da path espliciti.
tokenizer_path: path a tokenizer.json. Se None usa un tokenizer
fallback che emette token IDs anziché LaTeX — scarica il modello
completo via ModelHub::ensure_single(PpStructureModel::FormulaRec).
Sourcepub fn recognize(&self, image: &RgbImage) -> Result<FormulaResult, OcrError>
pub fn recognize(&self, image: &RgbImage) -> Result<FormulaResult, OcrError>
Riconosce la formula nell’immagine crop → stringa LaTeX.
Se self.decoder_enabled == false (default) restituisce
FormulaResult { latex: String::new(), score: 0.0 } senza alcuna
inferenza. Il decoder autoregressive può impiegare fino a 2560 step
(≈1.5 s/GPU, ≈3 s/CPU per formula complessa).
image deve essere il crop della regione formula (da LayoutAnalyzer
con LayoutClass::DisplayFormula o InlineFormula).
Auto Trait Implementations§
impl !RefUnwindSafe for FormulaRecognizer
impl !UnwindSafe for FormulaRecognizer
impl Freeze for FormulaRecognizer
impl Send for FormulaRecognizer
impl Sync for FormulaRecognizer
impl Unpin for FormulaRecognizer
impl UnsafeUnpin for FormulaRecognizer
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.