pub enum NormalizationConfig {
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 NormalizationConfig
impl NormalizationConfig
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::{NormalizationConfig, NormalizationPreset};
let (mean, std) = NormalizationConfig::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 NormalizationConfig
impl Clone for NormalizationConfig
Source§impl Debug for NormalizationConfig
impl Debug for NormalizationConfig
Source§impl<'de> Deserialize<'de> for NormalizationConfig
impl<'de> Deserialize<'de> for NormalizationConfig
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 NormalizationConfig
impl PartialEq for NormalizationConfig
Source§impl Serialize for NormalizationConfig
impl Serialize for NormalizationConfig
impl StructuralPartialEq for NormalizationConfig
Auto Trait Implementations§
impl Freeze for NormalizationConfig
impl RefUnwindSafe for NormalizationConfig
impl Send for NormalizationConfig
impl Sync for NormalizationConfig
impl Unpin for NormalizationConfig
impl UnsafeUnpin for NormalizationConfig
impl UnwindSafe for NormalizationConfig
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