pub struct DecodedTensor(/* private fields */);
Expand description
Implementations§
Source§impl DecodedTensor
impl DecodedTensor
Source§impl DecodedTensor
impl DecodedTensor
Sourcepub fn from_image(
image: impl Into<DynamicImage>,
) -> Result<DecodedTensor, TensorImageLoadError>
pub fn from_image( image: impl Into<DynamicImage>, ) -> Result<DecodedTensor, TensorImageLoadError>
Construct a tensor from something that can be turned into a image::DynamicImage
.
Requires the image
feature.
Sourcepub fn from_dynamic_image(
image: DynamicImage,
) -> Result<DecodedTensor, TensorImageLoadError>
pub fn from_dynamic_image( image: DynamicImage, ) -> Result<DecodedTensor, TensorImageLoadError>
Construct a tensor from image::DynamicImage
.
Requires the image
feature.
pub fn try_decode( maybe_encoded_tensor: Tensor, ) -> Result<Self, TensorImageLoadError>
pub fn decode_jpeg_bytes( jpeg_bytes: &Buffer<u8>, [expected_height, expected_width, expected_channels]: [u64; 3], ) -> Result<DecodedTensor, TensorImageLoadError>
Methods from Deref<Target = Tensor>§
pub fn id(&self) -> TensorId
pub fn shape(&self) -> &[TensorDimension]
Sourcepub fn shape_short(&self) -> &[TensorDimension]
pub fn shape_short(&self) -> &[TensorDimension]
Returns the shape of the tensor with all trailing dimensions of size 1 ignored.
If all dimension sizes are one, this returns only the first dimension.
pub fn num_dim(&self) -> usize
Sourcepub fn image_height_width_channels(&self) -> Option<[u64; 3]>
pub fn image_height_width_channels(&self) -> Option<[u64; 3]>
If the tensor can be interpreted as an image, return the height, width, and channels/depth of it.
Sourcepub fn is_shaped_like_an_image(&self) -> bool
pub fn is_shaped_like_an_image(&self) -> bool
Returns true if the tensor can be interpreted as an image.
Sourcepub fn is_vector(&self) -> bool
pub fn is_vector(&self) -> bool
Returns true if either all dimensions have size 1 or only a single dimension has a size larger than 1.
Empty tensors return false.
pub fn meaning(&self) -> TensorDataMeaning
Sourcepub fn get_with_image_coords(
&self,
x: u64,
y: u64,
channel: u64,
) -> Option<TensorElement>
pub fn get_with_image_coords( &self, x: u64, y: u64, channel: u64, ) -> Option<TensorElement>
Query with x, y, channel indices.
Allows to query values for any image like tensor even if it has more or less dimensions than 3.
(useful for sampling e.g. N x M x C x 1
tensor which is a valid image)
pub fn get(&self, index: &[u64]) -> Option<TensorElement>
pub fn dtype(&self) -> TensorDataType
pub fn size_in_bytes(&self) -> usize
Sourcepub fn could_be_dynamic_image(&self) -> bool
pub fn could_be_dynamic_image(&self) -> bool
Predicts if Self::to_dynamic_image
is likely to succeed, without doing anything expensive
Sourcepub fn to_dynamic_image(&self) -> Result<DynamicImage, TensorImageSaveError>
pub fn to_dynamic_image(&self) -> Result<DynamicImage, TensorImageSaveError>
Try to convert an image-like tensor into an image::DynamicImage
.
Trait Implementations§
Source§impl AsRef<Tensor> for DecodedTensor
impl AsRef<Tensor> for DecodedTensor
Source§impl Borrow<Tensor> for DecodedTensor
impl Borrow<Tensor> for DecodedTensor
Source§impl Clone for DecodedTensor
impl Clone for DecodedTensor
Source§fn clone(&self) -> DecodedTensor
fn clone(&self) -> DecodedTensor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl TryFrom<Tensor> for DecodedTensor
impl TryFrom<Tensor> for DecodedTensor
Auto Trait Implementations§
impl Freeze for DecodedTensor
impl RefUnwindSafe for DecodedTensor
impl Send for DecodedTensor
impl Sync for DecodedTensor
impl Unpin for DecodedTensor
impl UnwindSafe for DecodedTensor
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
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 more