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: TensorRGB 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
impl VisionSample
Sourcepub fn new(image: Tensor, label: Option<i64>) -> Result<Self>
pub fn new(image: Tensor, label: Option<i64>) -> Result<Self>
Validates RGB shape and constructs a sample with no detection targets.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validates tensor/target shapes and finite in-bounds coordinates.
Sourcepub fn to_float(self) -> Result<Self>
pub fn to_float(self) -> Result<Self>
Converts RGB bytes to Float in [0,1]; Float inputs pass through.
Sourcepub fn resize(
self,
height: u32,
width: u32,
limits: ResourceLimits,
) -> Result<Self>
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.
Sourcepub fn horizontal_flip(self) -> Result<Self>
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.