pub struct SamRunner {
pub arch: SamArch,
pub weights: PathBuf,
pub device: Device,
pub config_path: Option<PathBuf>,
}Expand description
SAM runner — owns the resolved config and dispatches the
per-arch forward pass. SAM 1 / 2 / 3 differ enough in their
prompting that we keep the heavy result type
(SamPredictionAny) as a discriminated union the caller
matches on.
Fields§
§arch: SamArch§weights: PathBuf§device: Device§config_path: Option<PathBuf>Implementations§
Source§impl SamRunner
impl SamRunner
pub fn builder(arch: SamArch) -> SamRunnerBuilder
Sourcepub fn summary(&self) -> String
pub fn summary(&self) -> String
Print a human-readable summary — what the CLI prints before any per-arch image processing.
Sourcepub fn predict_image(
&self,
rgb: &[u8],
h_in: usize,
w_in: usize,
points: Option<(&[f32], &[f32])>,
boxes: Option<&[f32]>,
text_tokens: &[u32],
) -> Result<SamPredictionAny>
pub fn predict_image( &self, rgb: &[u8], h_in: usize, w_in: usize, points: Option<(&[f32], &[f32])>, boxes: Option<&[f32]>, text_tokens: &[u32], ) -> Result<SamPredictionAny>
End-to-end forward: image bytes → masks. Dispatches to the right per-arch entrypoint:
- SAM 1 →
Sam::forward(multimask = true) - SAM 2 →
Sam2::predict_image(multimask = true) - SAM 3 →
Sam3::predict_image_textwith the suppliedtext_tokens(required for SAM 3 — its decoder is text-conditioned). Pass an empty slice for arches that don’t use it.
rgb is HWC u8; points is (xy_pairs, labels) with one
label per (x, y) pair (1 = foreground, 0 = background).
SAM-arch-specific defaults applied:
cfgderived from environment variables (RLX_SAM_VARIANTfor v1: vit_b/l/h;RLX_SAM2_VARIANTfor v2: tiny/small/ base_plus/large); falls back to the smallest variant.multimask_output = truefor v1 + v2.- SAM 3 vit defaults to
base.
Auto Trait Implementations§
impl Freeze for SamRunner
impl RefUnwindSafe for SamRunner
impl Send for SamRunner
impl Sync for SamRunner
impl Unpin for SamRunner
impl UnsafeUnpin for SamRunner
impl UnwindSafe for SamRunner
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
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