#[non_exhaustive]pub enum NormalizeOverride {
Preset(NormalizationPreset),
MeanStd {
mean: [f32; 3],
std: [f32; 3],
},
}Expand description
A normalize override: a preset name or R,G,B/R,G,B, a per-channel
mean and standard deviation in the 0–1 domain as Hugging Face and
torchvision write them.
use edgefirst_decoder::model_config::NormalizeOverride;
use edgefirst_tensor::NormalizationPreset;
let n: NormalizeOverride = "0.485,0.456,0.406/0.229,0.224,0.225".parse().unwrap();
assert_eq!(n.to_string(), "0.485,0.456,0.406/0.229,0.224,0.225");
assert_eq!(
"unsigned".parse::<NormalizeOverride>().unwrap(),
NormalizeOverride::Preset(NormalizationPreset::Unsigned)
);
assert!("0,0,0/0,1,1".parse::<NormalizeOverride>().is_err());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Preset(NormalizationPreset)
A named preset.
MeanStd
Explicit mean and standard deviation, 0–1 domain.
Implementations§
Source§impl NormalizeOverride
impl NormalizeOverride
Sourcepub fn to_normalization(&self) -> Result<Normalization, ModelConfigError>
pub fn to_normalization(&self) -> Result<Normalization, ModelConfigError>
The normalization on 0–255 values.
§Errors
ModelConfigError::Override for a non-finite mean or a standard
deviation that is not finite and positive.
Trait Implementations§
Source§impl Clone for NormalizeOverride
impl Clone for NormalizeOverride
impl Copy for NormalizeOverride
Source§impl Debug for NormalizeOverride
impl Debug for NormalizeOverride
Source§impl Display for NormalizeOverride
impl Display for NormalizeOverride
Source§impl FromStr for NormalizeOverride
impl FromStr for NormalizeOverride
Source§impl PartialEq for NormalizeOverride
impl PartialEq for NormalizeOverride
impl StructuralPartialEq for NormalizeOverride
Auto Trait Implementations§
impl Freeze for NormalizeOverride
impl RefUnwindSafe for NormalizeOverride
impl Send for NormalizeOverride
impl Sync for NormalizeOverride
impl Unpin for NormalizeOverride
impl UnsafeUnpin for NormalizeOverride
impl UnwindSafe for NormalizeOverride
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,
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