pub struct Processor {Show 18 fields
pub image_width: u32,
pub image_height: u32,
pub images_transform_info: Vec<ImageTransformInfo>,
pub resize_mode: ResizeMode,
pub resize_filter: &'static str,
pub padding_value: u8,
pub do_normalize: bool,
pub image_mean: Vec<f32>,
pub image_std: Vec<f32>,
pub nchw: bool,
pub image_tensor_layout: ImageTensorLayout,
pub vocab: Vec<String>,
pub unsigned: bool,
pub logits_sampler: Option<LogitsSampler>,
pub pad_image: bool,
pub pad_size: usize,
pub up_scale: f32,
pub do_resize: bool,
}Expand description
Image and text processing pipeline with tokenization and transformation capabilities.
Fields§
§image_width: u32§image_height: u32§images_transform_info: Vec<ImageTransformInfo>§resize_mode: ResizeMode§resize_filter: &'static str§padding_value: u8§do_normalize: bool§image_mean: Vec<f32>§image_std: Vec<f32>§nchw: bool§image_tensor_layout: ImageTensorLayout§vocab: Vec<String>§unsigned: bool§logits_sampler: Option<LogitsSampler>§pad_image: bool§pad_size: usize§up_scale: f32§do_resize: boolImplementations§
Source§impl Processor
impl Processor
Sourcepub fn with_image_width(self, x: u32) -> Self
pub fn with_image_width(self, x: u32) -> Self
Sourcepub fn image_width(&self) -> u32
pub fn image_width(&self) -> u32
Sourcepub fn with_image_height(self, x: u32) -> Self
pub fn with_image_height(self, x: u32) -> Self
Sourcepub fn image_height(&self) -> u32
pub fn image_height(&self) -> u32
Sourcepub fn with_images_transform_info(self, x: &[ImageTransformInfo]) -> Self
pub fn with_images_transform_info(self, x: &[ImageTransformInfo]) -> Self
Sets the images_transform_info field from a slice.
§Arguments
x- A slice of elements to be converted into a vector
§Returns
Returns Self for method chaining.
§Note
If the slice is empty, the field remains unchanged.
§Example
let obj = Processor::default().with_images_transform_info(&[item1, item2]);Generated by aksr - Builder pattern macro
Sourcepub fn images_transform_info(&self) -> &[ImageTransformInfo]
pub fn images_transform_info(&self) -> &[ImageTransformInfo]
Sourcepub fn into_images_transform_info(self) -> Vec<ImageTransformInfo>
pub fn into_images_transform_info(self) -> Vec<ImageTransformInfo>
Consumes self and returns the images_transform_info field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns the owned value of type Vec < ImageTransformInfo >.
§Example
let obj = Processor::default().with_images_transform_info(value);
let value = obj.into_images_transform_info();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn take_images_transform_info(&mut self) -> Vec<ImageTransformInfo>
pub fn take_images_transform_info(&mut self) -> Vec<ImageTransformInfo>
Takes the images_transform_info field and replaces it with Default::default().
This method moves the value out and replaces it with the default value, allowing you to continue using the struct.
§Returns
Returns the owned value of type Vec < ImageTransformInfo >.
§Note
Requires the field type Vec < ImageTransformInfo > to implement Default. Prefer this when you want to keep using the instance.
§Example
let mut obj = Processor::default().with_images_transform_info(value);
let value = obj.take_images_transform_info();
// obj.images_transform_info is now set to Default::default()Generated by aksr - Builder pattern macro
Sourcepub fn with_resize_mode(self, x: ResizeMode) -> Self
pub fn with_resize_mode(self, x: ResizeMode) -> Self
Sourcepub fn resize_mode(&self) -> &ResizeMode
pub fn resize_mode(&self) -> &ResizeMode
Sourcepub fn into_resize_mode(self) -> ResizeMode
pub fn into_resize_mode(self) -> ResizeMode
Consumes self and returns the resize_mode field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns the owned value of type ResizeMode.
§Example
let obj = Processor::default().with_resize_mode(value);
let value = obj.into_resize_mode();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn with_resize_filter(self, x: &'static str) -> Self
pub fn with_resize_filter(self, x: &'static str) -> Self
Sourcepub fn resize_filter(&self) -> &'static str
pub fn resize_filter(&self) -> &'static str
Sourcepub fn into_resize_filter(self) -> &'static str
pub fn into_resize_filter(self) -> &'static str
Consumes self and returns the resize_filter field.
This method moves the reference out of the struct.
§Returns
Returns the reference of type & ’static str.
§Example
let obj = Processor::default();
let value = obj.into_resize_filter();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn with_padding_value(self, x: u8) -> Self
pub fn with_padding_value(self, x: u8) -> Self
Sourcepub fn padding_value(&self) -> u8
pub fn padding_value(&self) -> u8
Sourcepub fn with_do_normalize(self, x: bool) -> Self
pub fn with_do_normalize(self, x: bool) -> Self
Sourcepub fn do_normalize(&self) -> bool
pub fn do_normalize(&self) -> bool
Sourcepub fn with_image_mean(self, x: &[f32]) -> Self
pub fn with_image_mean(self, x: &[f32]) -> Self
Sets the image_mean field from a slice.
§Arguments
x- A slice of elements to be converted into a vector
§Returns
Returns Self for method chaining.
§Note
If the slice is empty, the field remains unchanged.
§Example
let obj = Processor::default().with_image_mean(&[item1, item2]);Generated by aksr - Builder pattern macro
Sourcepub fn image_mean(&self) -> &[f32]
pub fn image_mean(&self) -> &[f32]
Sourcepub fn into_image_mean(self) -> Vec<f32>
pub fn into_image_mean(self) -> Vec<f32>
Consumes self and returns the image_mean field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns the owned value of type Vec < f32 >.
§Example
let obj = Processor::default().with_image_mean(value);
let value = obj.into_image_mean();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn take_image_mean(&mut self) -> Vec<f32>
pub fn take_image_mean(&mut self) -> Vec<f32>
Takes the image_mean field and replaces it with Default::default().
This method moves the value out and replaces it with the default value, allowing you to continue using the struct.
§Returns
Returns the owned value of type Vec < f32 >.
§Note
Requires the field type Vec < f32 > to implement Default. Prefer this when you want to keep using the instance.
§Example
let mut obj = Processor::default().with_image_mean(value);
let value = obj.take_image_mean();
// obj.image_mean is now set to Default::default()Generated by aksr - Builder pattern macro
Sourcepub fn with_image_std(self, x: &[f32]) -> Self
pub fn with_image_std(self, x: &[f32]) -> Self
Sets the image_std field from a slice.
§Arguments
x- A slice of elements to be converted into a vector
§Returns
Returns Self for method chaining.
§Note
If the slice is empty, the field remains unchanged.
§Example
let obj = Processor::default().with_image_std(&[item1, item2]);Generated by aksr - Builder pattern macro
Sourcepub fn into_image_std(self) -> Vec<f32>
pub fn into_image_std(self) -> Vec<f32>
Consumes self and returns the image_std field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns the owned value of type Vec < f32 >.
§Example
let obj = Processor::default().with_image_std(value);
let value = obj.into_image_std();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn take_image_std(&mut self) -> Vec<f32>
pub fn take_image_std(&mut self) -> Vec<f32>
Takes the image_std field and replaces it with Default::default().
This method moves the value out and replaces it with the default value, allowing you to continue using the struct.
§Returns
Returns the owned value of type Vec < f32 >.
§Note
Requires the field type Vec < f32 > to implement Default. Prefer this when you want to keep using the instance.
§Example
let mut obj = Processor::default().with_image_std(value);
let value = obj.take_image_std();
// obj.image_std is now set to Default::default()Generated by aksr - Builder pattern macro
Sourcepub fn with_image_tensor_layout(self, x: ImageTensorLayout) -> Self
pub fn with_image_tensor_layout(self, x: ImageTensorLayout) -> Self
Sourcepub fn image_tensor_layout(&self) -> &ImageTensorLayout
pub fn image_tensor_layout(&self) -> &ImageTensorLayout
Sourcepub fn into_image_tensor_layout(self) -> ImageTensorLayout
pub fn into_image_tensor_layout(self) -> ImageTensorLayout
Consumes self and returns the image_tensor_layout field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns the owned value of type ImageTensorLayout.
§Example
let obj = Processor::default().with_image_tensor_layout(value);
let value = obj.into_image_tensor_layout();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn with_vocab(self, x: &[&str]) -> Self
pub fn with_vocab(self, x: &[&str]) -> Self
Sets the vocab field from a slice of string slices.
§Arguments
x- A slice of string slices that will be automatically converted toVec<String>
§Returns
Returns Self for method chaining.
§Note
If the slice is empty, the field remains unchanged.
§Example
let obj = Processor::default().with_vocab(&["str1", "str2"]);Generated by aksr - Builder pattern macro
Sourcepub fn with_vocab_owned(self, x: &[String]) -> Self
pub fn with_vocab_owned(self, x: &[String]) -> Self
Sets the vocab field from a slice of owned strings.
§Arguments
x- A slice ofStringto be cloned into the vector
§Returns
Returns Self for method chaining.
§Note
This method is useful when you already have a Vec<String> and want to avoid converting to &[&str].
If the slice is empty, the field remains unchanged.
§Example
let strings = vec![String::from("a"), String::from("b")];
let obj = Processor::default().with_vocab_owned(&strings);Generated by aksr - Builder pattern macro
Sourcepub fn into_vocab(self) -> Vec<String>
pub fn into_vocab(self) -> Vec<String>
Consumes self and returns the vocab field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns the owned value of type Vec < String >.
§Example
let obj = Processor::default().with_vocab(value);
let value = obj.into_vocab();
// obj is now consumed and cannot be usedGenerated by aksr - Builder pattern macro
Sourcepub fn take_vocab(&mut self) -> Vec<String>
pub fn take_vocab(&mut self) -> Vec<String>
Takes the vocab field and replaces it with Default::default().
This method moves the value out and replaces it with the default value, allowing you to continue using the struct.
§Returns
Returns the owned value of type Vec < String >.
§Note
Requires the field type Vec < String > to implement Default. Prefer this when you want to keep using the instance.
§Example
let mut obj = Processor::default().with_vocab(value);
let value = obj.take_vocab();
// obj.vocab is now set to Default::default()Generated by aksr - Builder pattern macro
Sourcepub fn with_unsigned(self, x: bool) -> Self
pub fn with_unsigned(self, x: bool) -> Self
Sourcepub fn with_logits_sampler(self, x: LogitsSampler) -> Self
pub fn with_logits_sampler(self, x: LogitsSampler) -> Self
Sets the optional logits_sampler field.
§Arguments
x- The value that will be automatically wrapped inSome
§Returns
Returns Self for method chaining.
§Note
The value is automatically wrapped in Some, so you don’t need to pass Some(value).
§Example
let obj = Processor::default().with_logits_sampler(value);Generated by aksr - Builder pattern macro
Sourcepub fn logits_sampler(&self) -> Option<&LogitsSampler>
pub fn logits_sampler(&self) -> Option<&LogitsSampler>
Sourcepub fn into_logits_sampler(self) -> Option<LogitsSampler>
pub fn into_logits_sampler(self) -> Option<LogitsSampler>
Consumes self and returns the logits_sampler field.
This method moves the owned value out of the struct without cloning.
§Returns
Returns Option
§Example
let obj = Processor::default().with_logits_sampler(value);
let value = obj.into_logits_sampler();Generated by aksr - Builder pattern macro
Sourcepub fn take_logits_sampler(&mut self) -> Option<LogitsSampler>
pub fn take_logits_sampler(&mut self) -> Option<LogitsSampler>
Takes the logits_sampler field, leaving None in its place.
This method moves the value out and replaces it with None, allowing you to continue using the struct.
§Returns
Returns Option
§Note
This does not require the inner type to implement Default.
§Example
let mut obj = Processor::default().with_logits_sampler(value);
let value = obj.take_logits_sampler();
// obj.logits_sampler is now NoneGenerated by aksr - Builder pattern macro
Sourcepub fn with_pad_image(self, x: bool) -> Self
pub fn with_pad_image(self, x: bool) -> Self
Sourcepub fn with_pad_size(self, x: usize) -> Self
pub fn with_pad_size(self, x: usize) -> Self
Sourcepub fn with_up_scale(self, x: f32) -> Self
pub fn with_up_scale(self, x: f32) -> Self
Sourcepub fn with_do_resize(self, x: bool) -> Self
pub fn with_do_resize(self, x: bool) -> Self
Source§impl Processor
impl Processor
pub fn try_from_config(config: &ProcessorConfig) -> Result<Self>
pub fn reset_image0_status(&mut self)
pub fn hwc_to_chw(input: &[f32], h: usize, w: usize) -> Vec<f32>
pub fn hwc_to_chw_with_normalize_and_unsigned( input: &[f32], h: usize, w: usize, ) -> Vec<f32>
pub fn hwc_to_chw_with_normalize(input: &[f32], h: usize, w: usize) -> Vec<f32>
pub fn hwc_to_chw_with_unsigned(input: &[f32], h: usize, w: usize) -> Vec<f32>
pub fn hwc_to_chw_with_all_transforms( input: &[f32], h: usize, w: usize, do_normalize: bool, unsigned: bool, mean: &[f32], std: &[f32], ) -> Vec<f32>
pub fn hwc_to_chw_with_normalize_and_standardize( input: &[f32], h: usize, w: usize, mean: &[f32], std: &[f32], ) -> Vec<f32>
pub fn hwc_to_chw_with_unsigned_and_standardize( input: &[f32], h: usize, w: usize, mean: &[f32], std: &[f32], ) -> Vec<f32>
pub fn hwc_to_chw_with_standardize( input: &[f32], h: usize, w: usize, mean: &[f32], std: &[f32], ) -> Vec<f32>
pub fn process_images_f32(&mut self, xs: &[Image]) -> Result<Tensor>
pub fn process_images(&mut self, xs: &[Image]) -> Result<X>
pub fn par_resize(&self, xs: &[Image]) -> Result<(X, Vec<ImageTransformInfo>)>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Processor
impl RefUnwindSafe for Processor
impl Send for Processor
impl Sync for Processor
impl Unpin for Processor
impl UnsafeUnpin for Processor
impl UnwindSafe for Processor
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> 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.