pub struct ModularPredictor<R, P, I, O> {
pub image_reader: R,
pub preprocessor: P,
pub inference_engine: I,
pub postprocessor: O,
}Expand description
A modular predictor that composes granular components.
This struct demonstrates how to build a complete predictor using the granular traits. It provides the same interface as StandardPredictor but with composable components.
Fields§
§image_reader: RImage reader component
preprocessor: PPreprocessor component
inference_engine: IInference engine component
postprocessor: OPostprocessor component
Implementations§
Source§impl<R, P, I, O> ModularPredictor<R, P, I, O>where
R: ImageReader,
P: Preprocessor,
I: InferenceEngine<Input = P::Output>,
O: Postprocessor<InferenceOutput = I::Output, PreprocessOutput = P::Output>,
impl<R, P, I, O> ModularPredictor<R, P, I, O>where
R: ImageReader,
P: Preprocessor,
I: InferenceEngine<Input = P::Output>,
O: Postprocessor<InferenceOutput = I::Output, PreprocessOutput = P::Output>,
Trait Implementations§
Source§impl<R, P, I, O> StandardPredictor for ModularPredictor<R, P, I, O>where
R: ImageReader,
P: Preprocessor,
I: InferenceEngine<Input = P::Output>,
O: Postprocessor<InferenceOutput = I::Output, PreprocessOutput = P::Output, Config = P::Config>,
impl<R, P, I, O> StandardPredictor for ModularPredictor<R, P, I, O>where
R: ImageReader,
P: Preprocessor,
I: InferenceEngine<Input = P::Output>,
O: Postprocessor<InferenceOutput = I::Output, PreprocessOutput = P::Output, Config = P::Config>,
Source§type Config = <P as Preprocessor>::Config
type Config = <P as Preprocessor>::Config
The configuration type for this predictor.
Source§type Result = <O as Postprocessor>::Result
type Result = <O as Postprocessor>::Result
The result type of this predictor.
Source§type PreprocessOutput = <P as Preprocessor>::Output
type PreprocessOutput = <P as Preprocessor>::Output
The output type of the preprocessing step.
Source§type InferenceOutput = <I as InferenceEngine>::Output
type InferenceOutput = <I as InferenceEngine>::Output
The output type of the inference step.
Source§fn read_images<'a>(
&self,
paths: impl Iterator<Item = &'a str>,
) -> Result<Vec<RgbImage>, OCRError>
fn read_images<'a>( &self, paths: impl Iterator<Item = &'a str>, ) -> Result<Vec<RgbImage>, OCRError>
Reads images from the given paths. Read more
Source§fn preprocess(
&self,
images: Vec<RgbImage>,
config: Option<&Self::Config>,
) -> Result<Self::PreprocessOutput, OCRError>
fn preprocess( &self, images: Vec<RgbImage>, config: Option<&Self::Config>, ) -> Result<Self::PreprocessOutput, OCRError>
Preprocesses the given images. Read more
Source§fn infer(
&self,
input: &Self::PreprocessOutput,
) -> Result<Self::InferenceOutput, OCRError>
fn infer( &self, input: &Self::PreprocessOutput, ) -> Result<Self::InferenceOutput, OCRError>
Performs inference on the preprocessed input. Read more
Source§fn postprocess(
&self,
output: Self::InferenceOutput,
preprocessed: &Self::PreprocessOutput,
batch_data: &BatchData,
raw_images: Vec<RgbImage>,
config: Option<&Self::Config>,
) -> OcrResult<Self::Result>
fn postprocess( &self, output: Self::InferenceOutput, preprocessed: &Self::PreprocessOutput, batch_data: &BatchData, raw_images: Vec<RgbImage>, config: Option<&Self::Config>, ) -> OcrResult<Self::Result>
Postprocesses the inference output. Read more
Source§fn empty_result(&self) -> OcrResult<Self::Result>
fn empty_result(&self) -> OcrResult<Self::Result>
Returns an empty result for the predictor type. Read more
Auto Trait Implementations§
impl<R, P, I, O> Freeze for ModularPredictor<R, P, I, O>
impl<R, P, I, O> RefUnwindSafe for ModularPredictor<R, P, I, O>
impl<R, P, I, O> Send for ModularPredictor<R, P, I, O>
impl<R, P, I, O> Sync for ModularPredictor<R, P, I, O>
impl<R, P, I, O> Unpin for ModularPredictor<R, P, I, O>
impl<R, P, I, O> UnwindSafe for ModularPredictor<R, P, I, O>
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.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.