Skip to main content

Processor

Struct Processor 

Source
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: bool

Implementations§

Source§

impl Processor

Source

pub fn with_image_width(self, x: u32) -> Self

Sets the image_width field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_image_width(value);

Generated by aksr - Builder pattern macro

Source

pub fn image_width(&self) -> u32

Returns the value of the image_width field.

§Example
let obj = Processor::default();
let value = obj.image_width();

Generated by aksr - Builder pattern macro

Source

pub fn with_image_height(self, x: u32) -> Self

Sets the image_height field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_image_height(value);

Generated by aksr - Builder pattern macro

Source

pub fn image_height(&self) -> u32

Returns the value of the image_height field.

§Example
let obj = Processor::default();
let value = obj.image_height();

Generated by aksr - Builder pattern macro

Source

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

Source

pub fn images_transform_info(&self) -> &[ImageTransformInfo]

Returns a slice view of the images_transform_info field.

§Example
let obj = Processor::default();
let items = obj.images_transform_info();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

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

Source

pub fn with_resize_mode(self, x: ResizeMode) -> Self

Sets the resize_mode field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_resize_mode(value);

Generated by aksr - Builder pattern macro

Source

pub fn resize_mode(&self) -> &ResizeMode

Returns a reference to the resize_mode field.

§Example
let obj = Processor::default();
let value = obj.resize_mode();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

pub fn with_resize_filter(self, x: &'static str) -> Self

Sets the resize_filter field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_resize_filter(value);

Generated by aksr - Builder pattern macro

Source

pub fn resize_filter(&self) -> &'static str

Returns the value of the resize_filter field.

§Example
let obj = Processor::default();
let value = obj.resize_filter();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

pub fn with_padding_value(self, x: u8) -> Self

Sets the padding_value field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_padding_value(value);

Generated by aksr - Builder pattern macro

Source

pub fn padding_value(&self) -> u8

Returns the value of the padding_value field.

§Example
let obj = Processor::default();
let value = obj.padding_value();

Generated by aksr - Builder pattern macro

Source

pub fn with_do_normalize(self, x: bool) -> Self

Sets the do_normalize field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_do_normalize(value);

Generated by aksr - Builder pattern macro

Source

pub fn do_normalize(&self) -> bool

Returns the value of the do_normalize field.

§Example
let obj = Processor::default();
let value = obj.do_normalize();

Generated by aksr - Builder pattern macro

Source

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

Source

pub fn image_mean(&self) -> &[f32]

Returns a slice view of the image_mean field.

§Example
let obj = Processor::default();
let items = obj.image_mean();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

pub fn take_image_mean(&mut self) -> Vec<f32>
where Vec<f32>: Default,

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

Source

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

Source

pub fn image_std(&self) -> &[f32]

Returns a slice view of the image_std field.

§Example
let obj = Processor::default();
let items = obj.image_std();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

pub fn take_image_std(&mut self) -> Vec<f32>
where Vec<f32>: Default,

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

Source

pub fn with_nchw(self, x: bool) -> Self

Sets the nchw field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_nchw(value);

Generated by aksr - Builder pattern macro

Source

pub fn nchw(&self) -> bool

Returns the value of the nchw field.

§Example
let obj = Processor::default();
let value = obj.nchw();

Generated by aksr - Builder pattern macro

Source

pub fn with_image_tensor_layout(self, x: ImageTensorLayout) -> Self

Sets the image_tensor_layout field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_image_tensor_layout(value);

Generated by aksr - Builder pattern macro

Source

pub fn image_tensor_layout(&self) -> &ImageTensorLayout

Returns a reference to the image_tensor_layout field.

§Example
let obj = Processor::default();
let value = obj.image_tensor_layout();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

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 to Vec<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

Source

pub fn with_vocab_owned(self, x: &[String]) -> Self

Sets the vocab field from a slice of owned strings.

§Arguments
  • x - A slice of String to 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

Source

pub fn vocab(&self) -> &[String]

Returns a slice view of the vocab field.

§Example
let obj = Processor::default();
let items = obj.vocab();

Generated by aksr - Builder pattern macro

Source

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 used

Generated by aksr - Builder pattern macro

Source

pub fn take_vocab(&mut self) -> Vec<String>
where Vec<String>: Default,

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

Source

pub fn with_unsigned(self, x: bool) -> Self

Sets the unsigned field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_unsigned(value);

Generated by aksr - Builder pattern macro

Source

pub fn unsigned(&self) -> bool

Returns the value of the unsigned field.

§Example
let obj = Processor::default();
let value = obj.unsigned();

Generated by aksr - Builder pattern macro

Source

pub fn with_logits_sampler(self, x: LogitsSampler) -> Self

Sets the optional logits_sampler field.

§Arguments
  • x - The value that will be automatically wrapped in Some
§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

Source

pub fn logits_sampler(&self) -> Option<&LogitsSampler>

Returns an optional reference to the logits_sampler field.

§Example
let obj = Processor::default();
let value = obj.logits_sampler();

Generated by aksr - Builder pattern macro

Source

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 containing the field value, or None if the field was None.

§Example
let obj = Processor::default().with_logits_sampler(value);
let value = obj.into_logits_sampler();

Generated by aksr - Builder pattern macro

Source

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 containing the field value, or None if the field was None.

§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 None

Generated by aksr - Builder pattern macro

Source

pub fn with_pad_image(self, x: bool) -> Self

Sets the pad_image field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_pad_image(value);

Generated by aksr - Builder pattern macro

Source

pub fn pad_image(&self) -> bool

Returns the value of the pad_image field.

§Example
let obj = Processor::default();
let value = obj.pad_image();

Generated by aksr - Builder pattern macro

Source

pub fn with_pad_size(self, x: usize) -> Self

Sets the pad_size field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_pad_size(value);

Generated by aksr - Builder pattern macro

Source

pub fn pad_size(&self) -> usize

Returns the value of the pad_size field.

§Example
let obj = Processor::default();
let value = obj.pad_size();

Generated by aksr - Builder pattern macro

Source

pub fn with_up_scale(self, x: f32) -> Self

Sets the up_scale field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_up_scale(value);

Generated by aksr - Builder pattern macro

Source

pub fn up_scale(&self) -> f32

Returns the value of the up_scale field.

§Example
let obj = Processor::default();
let value = obj.up_scale();

Generated by aksr - Builder pattern macro

Source

pub fn with_do_resize(self, x: bool) -> Self

Sets the do_resize field.

§Arguments
  • x - The new value to be assigned
§Returns

Returns Self for method chaining.

§Example
let obj = Processor::default().with_do_resize(value);

Generated by aksr - Builder pattern macro

Source

pub fn do_resize(&self) -> bool

Returns the value of the do_resize field.

§Example
let obj = Processor::default();
let value = obj.do_resize();

Generated by aksr - Builder pattern macro

Source§

impl Processor

Source

pub fn try_from_config(config: &ProcessorConfig) -> Result<Self>

Source

pub fn reset_image0_status(&mut self)

Source

pub fn hwc_to_chw(input: &[f32], h: usize, w: usize) -> Vec<f32>

Source

pub fn hwc_to_chw_with_normalize_and_unsigned( input: &[f32], h: usize, w: usize, ) -> Vec<f32>

Source

pub fn hwc_to_chw_with_normalize(input: &[f32], h: usize, w: usize) -> Vec<f32>

Source

pub fn hwc_to_chw_with_unsigned(input: &[f32], h: usize, w: usize) -> Vec<f32>

Source

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>

Source

pub fn hwc_to_chw_with_normalize_and_standardize( input: &[f32], h: usize, w: usize, mean: &[f32], std: &[f32], ) -> Vec<f32>

Source

pub fn hwc_to_chw_with_unsigned_and_standardize( input: &[f32], h: usize, w: usize, mean: &[f32], std: &[f32], ) -> Vec<f32>

Source

pub fn hwc_to_chw_with_standardize( input: &[f32], h: usize, w: usize, mean: &[f32], std: &[f32], ) -> Vec<f32>

Source

pub fn process_images_f32(&mut self, xs: &[Image]) -> Result<Tensor>

Source

pub fn process_images(&mut self, xs: &[Image]) -> Result<X>

Source

pub fn par_resize(&self, xs: &[Image]) -> Result<(X, Vec<ImageTransformInfo>)>

Trait Implementations§

Source§

impl Clone for Processor

Source§

fn clone(&self) -> Processor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Processor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Processor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more