pub struct Sam { /* private fields */ }Expand description
The full Segment Anything Model.
Implementations§
Source§impl Sam
impl Sam
Sourcepub fn new(cfg: SamConfig, rng: &mut LcgRng) -> VisionResult<Self>
pub fn new(cfg: SamConfig, rng: &mut LcgRng) -> VisionResult<Self>
Sourcepub fn prompt_encoder(&self) -> &PromptEncoder
pub fn prompt_encoder(&self) -> &PromptEncoder
Read-only access to the prompt encoder.
Sourcepub fn encode_image(&self, image: &[f32]) -> VisionResult<FeatureMap>
pub fn encode_image(&self, image: &[f32]) -> VisionResult<FeatureMap>
Encode an image into its dense embedding (embed_dim, grid, grid).
§Errors
Propagates encoder errors.
Sourcepub fn predict(
&self,
image: &[f32],
point_coords: &[f32],
point_labels: &[i32],
mask: Option<&[f32]>,
) -> VisionResult<MaskPrediction>
pub fn predict( &self, image: &[f32], point_coords: &[f32], point_labels: &[i32], mask: Option<&[f32]>, ) -> VisionResult<MaskPrediction>
End-to-end prediction from an image and a set of point prompts (plus an optional coarse mask prompt).
§Errors
Propagates encoder / prompt / decoder errors.
Auto Trait Implementations§
impl Freeze for Sam
impl RefUnwindSafe for Sam
impl Send for Sam
impl Sync for Sam
impl Unpin for Sam
impl UnsafeUnpin for Sam
impl UnwindSafe for Sam
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