Skip to main content

VisionSample

Struct VisionSample 

Source
pub struct VisionSample {
    pub image: Tensor,
    pub label: Option<i64>,
    pub boxes: Vec<BoundingBox>,
    pub keypoints: Vec<Keypoint>,
    pub mask: Option<Tensor>,
}
Expand description

Owned CHW RGB bytes and associated classification/detection targets.

Fields§

§image: Tensor

RGB tensor shaped [3, height, width]; Uint8 or normalized Float.

§label: Option<i64>

Optional classification label.

§boxes: Vec<BoundingBox>

Detection rectangles.

§keypoints: Vec<Keypoint>

Keypoints; geometric operations preserve their order.

§mask: Option<Tensor>

Optional integer segmentation mask shaped [height, width].

Implementations§

Source§

impl VisionSample

Source

pub fn new(image: Tensor, label: Option<i64>) -> Result<Self>

Validates RGB shape and constructs a sample with no detection targets.

Source

pub fn validate(&self) -> Result<()>

Validates tensor/target shapes and finite in-bounds coordinates.

Source

pub fn to_float(self) -> Result<Self>

Converts RGB bytes to Float in [0,1]; Float inputs pass through.

Source

pub fn resize( self, height: u32, width: u32, limits: ResourceLimits, ) -> Result<Self>

Resizes RGB with bilinear interpolation and masks with nearest-neighbor. All boxes/keypoints use the same scale factors. Does not mutate input storage.

Source

pub fn horizontal_flip(self) -> Result<Self>

Flips image, boxes and mask horizontally. Keypoint order is unchanged; callers must supply a left/right semantic permutation themselves.

Source

pub fn crop(self, top: u32, left: u32, height: u32, width: u32) -> Result<Self>

Crops to a checked rectangle, clips boxes, removes empty boxes and marks outside keypoints absent. Mask and image use the identical crop.

Trait Implementations§

Source§

impl Debug for VisionSample

Source§

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

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

impl DefaultCollate for VisionSample

Source§

type Batch = VisionBatch

Batch produced from a vector of this sample type.
Source§

fn default_collate(samples: Vec<Self>) -> Result<VisionBatch, CollateError>

Applies built-in typed collation.
Source§

impl DefaultConvert for VisionSample

Source§

type Output = VisionSample

Output produced from this sample type.
Source§

fn default_convert(self) -> Result<Self, CollateError>

Applies built-in conversion without automatic batching.
Source§

impl MemoryFootprint for VisionSample

Source§

fn resident_bytes(&self) -> usize

Returns the conservative logical payload size in bytes.
Source§

impl PinMemory for VisionSample

Source§

fn pin_memory(self, d: Device) -> Result<Self>

Pins this value for the requested accelerator.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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