Skip to main content

Sam2PromptEncoderWeights

Struct Sam2PromptEncoderWeights 

Source
pub struct Sam2PromptEncoderWeights {
Show 17 fields pub pe_gaussian: Vec<f32>, pub not_a_point_embed: Vec<f32>, pub point_embeddings: Vec<f32>, pub mask_conv1_w: Vec<f32>, pub mask_conv1_b: Vec<f32>, pub mask_ln1_g: Vec<f32>, pub mask_ln1_b: Vec<f32>, pub mask_conv2_w: Vec<f32>, pub mask_conv2_b: Vec<f32>, pub mask_ln2_g: Vec<f32>, pub mask_ln2_b: Vec<f32>, pub mask_conv3_w: Vec<f32>, pub mask_conv3_b: Vec<f32>, pub no_mask_embed: Vec<f32>, pub embed_dim: usize, pub mask_in_chans: usize, pub grid: usize,
}
Expand description

All weights consumed by prompt_encoder_forward. Loaded once from the safetensors file and then reused per prompt.

Fields§

§pe_gaussian: Vec<f32>

[2, embed_dim/2] Gaussian random projection used by the Fourier positional encoder.

§not_a_point_embed: Vec<f32>

[embed_dim] learned token for “not a point” padding label (used when there are points but no boxes — labels of -1).

§point_embeddings: Vec<f32>

[4, embed_dim] learned per-label embeddings: 0 → background point, 1 → foreground point, 2 → box top-left corner, 3 → box bottom-right corner.

§mask_conv1_w: Vec<f32>

Mask downscaling stack (Conv2d → LN2d → GELU → Conv2d → LN2d → GELU → Conv2d).

§mask_conv1_b: Vec<f32>§mask_ln1_g: Vec<f32>§mask_ln1_b: Vec<f32>§mask_conv2_w: Vec<f32>§mask_conv2_b: Vec<f32>§mask_ln2_g: Vec<f32>§mask_ln2_b: Vec<f32>§mask_conv3_w: Vec<f32>§mask_conv3_b: Vec<f32>§no_mask_embed: Vec<f32>

[embed_dim] learned token broadcast over the image grid when no mask prompt is supplied.

§embed_dim: usize§mask_in_chans: usize

mask_in_chans (16 for all SAM 2 variants).

§grid: usize

Grid edge length (64 for SAM 2’s stride-16 path).

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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