pub enum Normalization {
Preset(NormalizationPreset),
MeanStd {
mean: Vec<f32>,
std: Vec<f32>,
},
}Expand description
Input normalization: a named preset or explicit per-channel
mean/std, both defined as (x - mean) / std on 0–255 values.
Variants§
Preset(NormalizationPreset)
Named preset shared with validation.normalization.
MeanStd
Explicit coefficients on the 0–255 scale. A single element applies to every channel.
Implementations§
Source§impl Normalization
impl Normalization
Sourcepub fn mean_std(&self, channels: usize) -> DecoderResult<(Vec<f32>, Vec<f32>)>
pub fn mean_std(&self, channels: usize) -> DecoderResult<(Vec<f32>, Vec<f32>)>
Resolve to per-channel (mean, std) vectors on the 0–255 scale,
each of length channels.
§Errors
DecoderError::InvalidConfig when the coefficient count is neither
1 nor channels, when any std is zero or non-finite, or when the
imagenet preset is used with a channel count other than 3.
use edgefirst_decoder::schema::{Normalization, NormalizationPreset};
let (mean, std) = Normalization::Preset(NormalizationPreset::Signed)
.mean_std(3)
.unwrap();
assert_eq!(mean, vec![127.5; 3]);
assert_eq!(std, vec![127.5; 3]);Trait Implementations§
Source§impl Clone for Normalization
impl Clone for Normalization
Source§impl Debug for Normalization
impl Debug for Normalization
Source§impl<'de> Deserialize<'de> for Normalization
impl<'de> Deserialize<'de> for Normalization
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Normalization
impl PartialEq for Normalization
Source§impl Serialize for Normalization
impl Serialize for Normalization
impl StructuralPartialEq for Normalization
Auto Trait Implementations§
impl Freeze for Normalization
impl RefUnwindSafe for Normalization
impl Send for Normalization
impl Sync for Normalization
impl Unpin for Normalization
impl UnsafeUnpin for Normalization
impl UnwindSafe for Normalization
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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 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> ⓘ
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