Skip to main content

SemanticConfig

Struct SemanticConfig 

Source
pub struct SemanticConfig { /* private fields */ }
Expand description

Static description of a semantic output, usually built from the model’s edgefirst.json by SemanticConfig::from_logical.

Implementations§

Source§

impl SemanticConfig

Source

pub fn scores( shape: &[usize], class_axis: usize, height_axis: usize, width_axis: usize, ) -> DecoderResult<Self>

Score map of shape, with the class, height and width axes at the given positions. Every other axis must have size 1.

Defaults: bilinear upsampling with align_corners = false, DecodeMode::Accurate, no activation applied, not quantized.

Source

pub fn class_map( shape: &[usize], height_axis: usize, width_axis: usize, ) -> DecoderResult<Self>

Class map of shape with the height and width axes at the given positions. Every other axis must have size 1.

Source

pub fn from_logical(logical: &LogicalOutput) -> DecoderResult<Self>

Builds the configuration of a segmentation or masks logical output with decoder: semantic, or of a ModelPack segmentation output, which is NHWC and decoded in DecodeMode::Fast unless it says otherwise.

Source

pub fn with_upsample(self, upsample: Upsample) -> DecoderResult<Self>

Sets the score-map upsampling. Bicubic is not supported.

Source

pub fn with_mode(self, mode: DecodeMode) -> Self

Sets the default decode mode.

Source

pub fn with_threshold(self, threshold: f32) -> Self

Sets the single-channel foreground threshold, in the space of the scores after activation.

Source

pub fn with_activation(self, activation: Activation) -> DecoderResult<Self>

Declares an activation the model already applied to the scores.

§Errors

See Self::with_activation_required.

Source

pub fn with_activation_required( self, activation: Activation, ) -> DecoderResult<Self>

Declares the activation the scores still need. It is applied after resampling, as reference pipelines do, so it leaves the class map unchanged and sets how decode_semantic computes confidence.

§Errors

DecoderError::InvalidConfig when an activation is both applied and required, or a single channel declares softmax; DecoderError::NotSupported for tanh.

Source

pub fn with_quantization(self, quantization: Quantization) -> Self

Quantization of integer scores, used when the tensor carries none.

Source

pub fn with_name(self, name: impl Into<String>) -> Self

Names the output so select_output prefers the tensor of that name.

Source

pub fn with_position(self, index: usize, count: usize) -> Self

Records the output’s index among the model’s count outputs, which select_output uses when several outputs share its shape.

Source

pub fn input(&self) -> SemanticInput

What the output holds.

Source

pub fn name(&self) -> Option<&str>

Output name, when known.

Source

pub fn shape(&self) -> &[usize]

Expected tensor shape.

Source

pub fn layout(&self) -> SemanticLayout

Axis positions in Self::shape.

Source

pub fn classes(&self) -> usize

Number of classes the decoded class map can contain: the channel count, 2 for a single thresholded channel, 0 when unknown (a class map).

Source

pub fn height(&self) -> usize

Score-map height.

Source

pub fn width(&self) -> usize

Score-map width.

Source

pub fn upsample(&self) -> Upsample

Score-map upsampling.

Source

pub fn mode(&self) -> DecodeMode

Default decode mode.

Source

pub fn threshold(&self) -> f32

Single-channel foreground threshold in the space of the scores: the configured value, else 0.5 for probabilities and 0.0 for logits.

Source

pub fn matches(&self, tensor: &TensorDyn) -> bool

Whether tensor has this output’s shape, ignoring axes of size 1.

Trait Implementations§

Source§

impl Clone for SemanticConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SemanticConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SemanticConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SemanticConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more