pub struct ImageOps { /* private fields */ }Expand description
GPU image operations sharing the caller’s model context and compilation cache.
Implementations§
Source§impl ImageOps
impl ImageOps
Sourcepub fn prepare_affine_rgb(
&self,
input: &TensorDesc,
crops: usize,
height: usize,
width: usize,
sampling: RgbSampling,
) -> Result<Arc<PreparedModel>>
pub fn prepare_affine_rgb( &self, input: &TensorDesc, crops: usize, height: usize, width: usize, sampling: RgbSampling, ) -> Result<Arc<PreparedModel>>
Prepare several affine crops from one packed RGB image [1,h,w,3].
The second input is contiguous F32 [crops,2,3] (General layout), mapping
integer output pixel centers to source coordinates. Output is U8 NHWC.
Sampling uses the explicit FP32 border/arithmetic/rounding contract.
Non-finite or excessively large coordinates produce black, never an unsafe
integer conversion. Matrices are runtime data, not part of the cache key.
Sourcepub fn affine_rgb_fragment(
&self,
input: &TensorDesc,
crops: usize,
height: usize,
width: usize,
sampling: RgbSampling,
) -> Result<ModelFragment>
pub fn affine_rgb_fragment( &self, input: &TensorDesc, crops: usize, height: usize, width: usize, sampling: RgbSampling, ) -> Result<ModelFragment>
Recordable affine crop sampling for composition with model kernels.
Sourcepub fn affine_packed_rgb_fragment(
&self,
input: &TensorDesc,
crops: usize,
height: usize,
width: usize,
sampling: RgbSampling,
) -> Result<ModelFragment>
pub fn affine_packed_rgb_fragment( &self, input: &TensorDesc, crops: usize, height: usize, width: usize, sampling: RgbSampling, ) -> Result<ModelFragment>
Sample crops from differently sized RGB images in one packed byte buffer.
Inputs are U8 [bytes], F32 [crops,2,3] inverse matrices, and U32
[crops,3] records (byte_offset, width, height). Repeated records sample
several faces from one image without duplicating its pixels. Geometry is
runtime data: changing image sizes does not compile another graph.
Axes must be 1..=32767. Invalid records produce black; source reads are
bounded to the byte buffer.
Sourcepub fn affine_rgb(
&self,
image: &DeviceTensor,
inverse: &DeviceTensor,
height: usize,
width: usize,
sampling: RgbSampling,
) -> Result<Inference>
pub fn affine_rgb( &self, image: &DeviceTensor, inverse: &DeviceTensor, height: usize, width: usize, sampling: RgbSampling, ) -> Result<Inference>
Sample resident RGB into resident crops without a host wait or readback.
Source§impl ImageOps
impl ImageOps
Sourcepub fn prepare_composite_rgb(
&self,
image: &TensorDesc,
crop: &TensorDesc,
mode: RgbComposite,
) -> Result<Arc<PreparedModel>>
pub fn prepare_composite_rgb( &self, image: &TensorDesc, crop: &TensorDesc, mode: RgbComposite, ) -> Result<Arc<PreparedModel>>
Prepare affine compositing of one F32 NHWC RGB crop and its F32
[height,width] alpha mask into one U8 NHWC frame. RGB uses replicated
borders; mask sampling uses zero borders and clamps alpha to [0,1].
Inputs: frame, crop, mask, F32 [1,2,3] frame-to-crop matrix, F32 [5]
containing [left,top,right,bottom,blend]. Region bounds are exclusive
on right/bottom. Pixels outside it (or with invalid coordinates) are
unchanged. Blend is clamped to [0,1] and used only for QuantizedBlend.
Sourcepub fn composite_rgb_fragment(
&self,
image: &TensorDesc,
crop: &TensorDesc,
mode: RgbComposite,
) -> Result<ModelFragment>
pub fn composite_rgb_fragment( &self, image: &TensorDesc, crop: &TensorDesc, mode: RgbComposite, ) -> Result<ModelFragment>
Record compositing with directly bound frame, crop, mask, matrix and
region/blend inputs. Descriptors and arithmetic match prepare_composite_rgb.
Sourcepub fn composite_rgb(
&self,
image: &DeviceTensor,
crop: &DeviceTensor,
mask: &DeviceTensor,
matrix: &DeviceTensor,
region: [usize; 4],
blend: f32,
mode: RgbComposite,
) -> Result<Inference>
pub fn composite_rgb( &self, image: &DeviceTensor, crop: &DeviceTensor, mask: &DeviceTensor, matrix: &DeviceTensor, region: [usize; 4], blend: f32, mode: RgbComposite, ) -> Result<Inference>
Composite resident pixels. Bounds and blend are small host metadata; image, crop, mask and matrix never cross the host boundary.
Source§impl ImageOps
impl ImageOps
Sourcepub fn prepare_normalize_rgb(
&self,
input: &TensorDesc,
mean: [f32; 3],
std: [f32; 3],
) -> Result<Arc<PreparedModel>>
pub fn prepare_normalize_rgb( &self, input: &TensorDesc, mean: [f32; 3], std: [f32; 3], ) -> Result<Arc<PreparedModel>>
Prepare packed RGB U8 NHWC to F32 NCHW conversion, computing
(pixel / 255 - mean[channel]) / std[channel] in that order.
Sourcepub fn normalize_rgb_fragment(
&self,
input: &TensorDesc,
mean: [f32; 3],
std: [f32; 3],
) -> Result<ModelFragment>
pub fn normalize_rgb_fragment( &self, input: &TensorDesc, mean: [f32; 3], std: [f32; 3], ) -> Result<ModelFragment>
Recordable normalization with no slot pool or host staging. Connect its output directly to a model fragment in a caller-owned graph.
Sourcepub fn normalize_rgb(
&self,
input: &DeviceTensor,
mean: [f32; 3],
std: [f32; 3],
) -> Result<Inference>
pub fn normalize_rgb( &self, input: &DeviceTensor, mean: [f32; 3], std: [f32; 3], ) -> Result<Inference>
Normalize resident RGB pixels and change layout without a host boundary.
Source§impl ImageOps
impl ImageOps
Sourcepub fn prepare_resize_rgb(
&self,
input: &TensorDesc,
resize: RgbResize,
) -> Result<Arc<PreparedModel>>
pub fn prepare_resize_rgb( &self, input: &TensorDesc, resize: RgbResize, ) -> Result<Arc<PreparedModel>>
Prepare a reusable three-slot RGB resize/letterbox plan for contiguous
U8 NHWC [batch,height,width,3]. Only image bytes are runtime inputs.
Sourcepub fn resize_rgb_fragment(
&self,
input: &TensorDesc,
resize: RgbResize,
) -> Result<ModelFragment>
pub fn resize_rgb_fragment( &self, input: &TensorDesc, resize: RgbResize, ) -> Result<ModelFragment>
Recordable resize/letterbox for direct composition with a model graph.
Sourcepub fn resize_rgb(
&self,
image: &DeviceTensor,
resize: RgbResize,
) -> Result<Inference>
pub fn resize_rgb( &self, image: &DeviceTensor, resize: RgbResize, ) -> Result<Inference>
Resize a resident RGB batch; output padding is initialized to black on every replay. Retained outputs apply bounded per-shape backpressure.
Source§impl ImageOps
impl ImageOps
Sourcepub fn prepare_similarity_2d(
&self,
points: &TensorDesc,
template: &[[f32; 2]],
) -> Result<Arc<PreparedModel>>
pub fn prepare_similarity_2d( &self, points: &TensorDesc, template: &[[f32; 2]], ) -> Result<Arc<PreparedModel>>
Prepare FP32 similarity fitting for [batch,points,2]. Positive
non-overlapping strides allow direct landmark views of detection rows.
Template coordinates are immutable shape-plan data (2..=64 points).
Outputs: forward [batch,2,3], inverse [batch,2,3], status I32 [batch].
Status is zero for success and one for invalid/degenerate geometry; both
matrices are NaN on failure. Consumers must preserve/check status, not
treat a black crop from invalid geometry as a successful alignment.
Sourcepub fn similarity_2d_fragment(
&self,
points: &TensorDesc,
template: &[[f32; 2]],
) -> Result<ModelFragment>
pub fn similarity_2d_fragment( &self, points: &TensorDesc, template: &[[f32; 2]], ) -> Result<ModelFragment>
Recordable fit producing forward matrices, inverse matrices and status.
Sourcepub fn similarity_2d(
&self,
points: &DeviceTensor,
template: &[[f32; 2]],
) -> Result<Inference>
pub fn similarity_2d( &self, points: &DeviceTensor, template: &[[f32; 2]], ) -> Result<Inference>
Fit resident landmarks; no landmark or matrix readback is performed.
Source§impl ImageOps
impl ImageOps
Sourcepub fn prepare_encode_rgb_views(
&self,
input: &TensorDesc,
factor: usize,
encoding: RgbEncoding,
) -> Result<Arc<PreparedModel>>
pub fn prepare_encode_rgb_views( &self, input: &TensorDesc, factor: usize, encoding: RgbEncoding, ) -> Result<Arc<PreparedModel>>
Split packed U8 NHWC into interleaved F32 NCHW views. A factor of f produces f² views per image: view (dy,dx) samples image[yf+dy,xf+dx]. This is a lossless layout permutation before the selected normalization, not a resize. Both spatial dimensions must divide the factor.
Sourcepub fn prepare_decode_rgb_views(
&self,
input: &TensorDesc,
factor: usize,
encoding: RgbEncoding,
) -> Result<Arc<PreparedModel>>
pub fn prepare_decode_rgb_views( &self, input: &TensorDesc, factor: usize, encoding: RgbEncoding, ) -> Result<Arc<PreparedModel>>
Reassemble interleaved F32 NCHW views as F32 NHWC byte-level RGB. The view batch must be a multiple of factor². Unit values retain the network’s fractional output; Symmetric values use the documented clamp.
Sourcepub fn encode_rgb_views_fragment(
&self,
input: &TensorDesc,
factor: usize,
encoding: RgbEncoding,
) -> Result<ModelFragment>
pub fn encode_rgb_views_fragment( &self, input: &TensorDesc, factor: usize, encoding: RgbEncoding, ) -> Result<ModelFragment>
Record RGB view encoding with directly bound input pixels.
Sourcepub fn decode_rgb_views_fragment(
&self,
input: &TensorDesc,
factor: usize,
encoding: RgbEncoding,
) -> Result<ModelFragment>
pub fn decode_rgb_views_fragment( &self, input: &TensorDesc, factor: usize, encoding: RgbEncoding, ) -> Result<ModelFragment>
Record RGB view decoding with directly bound model output.
Sourcepub fn encode_rgb_views(
&self,
input: &DeviceTensor,
factor: usize,
encoding: RgbEncoding,
) -> Result<Inference>
pub fn encode_rgb_views( &self, input: &DeviceTensor, factor: usize, encoding: RgbEncoding, ) -> Result<Inference>
Encode resident pixels without a host boundary.
Sourcepub fn decode_rgb_views(
&self,
input: &DeviceTensor,
factor: usize,
encoding: RgbEncoding,
) -> Result<Inference>
pub fn decode_rgb_views( &self, input: &DeviceTensor, factor: usize, encoding: RgbEncoding, ) -> Result<Inference>
Decode resident model views without a host boundary.
Source§impl ImageOps
impl ImageOps
Sourcepub fn new(context: &ModelContext, cache_capacity: usize) -> Result<Self>
pub fn new(context: &ModelContext, cache_capacity: usize) -> Result<Self>
Create a bounded shape cache. Preparation is lazy, never per warm request.
Sourcepub fn prepare_patchify(
&self,
input: &TensorDesc,
patch: usize,
) -> Result<Arc<PreparedModel>>
pub fn prepare_patchify( &self, input: &TensorDesc, patch: usize, ) -> Result<Arc<PreparedModel>>
Prepare NCHW f32 patchification to [batch, patches, channels*p*p].
Within a patch, values are in channel, row, column order. No arithmetic
changes the values, including non-finite payloads. Both axes must divide p.
Sourcepub fn patchify_fragment(
&self,
input: &TensorDesc,
patch: usize,
) -> Result<ModelFragment>
pub fn patchify_fragment( &self, input: &TensorDesc, patch: usize, ) -> Result<ModelFragment>
Recordable patchification for direct composition with a model graph.
Auto Trait Implementations§
impl !Freeze for ImageOps
impl RefUnwindSafe for ImageOps
impl Send for ImageOps
impl Sync for ImageOps
impl Unpin for ImageOps
impl UnsafeUnpin for ImageOps
impl UnwindSafe for ImageOps
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> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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 more