pub enum MaskDecoderChoice {
None,
External {
program: PathBuf,
args: Vec<String>,
timeout_secs: u64,
},
Licensed,
}Expand description
Which decoder a SamSegmenter uses for sam-3.1 masks.
Meta’s mask payloads are base85 text around an arithmetic-coded body whose model only
Meta’s @meta-sam/parser defines, under the SAM License. The Apache-2.0 crates hold no
SAM-licensed code, so masks come through one of three choices:
| Choice | Each object is | Needs |
|---|---|---|
None (boxes, the default) | Its box in source pixels | Nothing |
External | Its mask, decoded by a program you installed | The program; it reads mask JSON on standard input and writes base64 rasters |
Licensed | Its mask, decoded in this process by the port of Meta’s codec | Feature sam-codec and a person’s recorded acceptance of the SAM License |
In .adk/vision.toml it is the [sam.masks] table, keyed by decoder.
§Example
use adk_vision::{MaskDecoderChoice, VisionConfig};
let config = VisionConfig::from_toml_str(r#"
[sam.masks]
decoder = "external"
program = "/opt/sam/bin/sam-mask-decode"
args = ["--json"]
timeout_secs = 30
"#).unwrap();
assert_eq!(
config.sam.masks,
MaskDecoderChoice::External {
program: "/opt/sam/bin/sam-mask-decode".into(),
args: vec!["--json".into()],
timeout_secs: 30,
}
);
let licensed = VisionConfig::from_toml_str("[sam.masks]\ndecoder = \"licensed\"").unwrap();
assert_eq!(licensed.sam.masks, MaskDecoderChoice::Licensed);
assert_eq!(VisionConfig::default().sam.masks, MaskDecoderChoice::None);Variants§
None
No decoder: each object is its box in source pixels.
External
A program the user installed, such as a wrapper around Meta’s parser.
It is started once per answer with args, reads a JSON array of
{"encoding", "width", "height", "payload"} on standard input and writes a JSON array
holding one base64 string per mask: height × width bytes, row-major, nonzero for a
set pixel. It is ended after timeout_secs.
Fields
Licensed
The Rust port of Meta’s codec (adk-vision-sam-codec, under the SAM License), in
this process: feature sam-codec, and a person’s recorded acceptance of the
SAM_MASK_CODEC_MANIFEST entry’s licence.
Implementations§
Source§impl MaskDecoderChoice
impl MaskDecoderChoice
Sourcepub fn external<A: Into<String>>(
program: impl Into<PathBuf>,
args: impl IntoIterator<Item = A>,
) -> Self
pub fn external<A: Into<String>>( program: impl Into<PathBuf>, args: impl IntoIterator<Item = A>, ) -> Self
An external program with arguments and the default timeout.
§Example
use adk_vision::MaskDecoderChoice;
let choice = MaskDecoderChoice::external("sam-mask-decode", ["--json"]);
assert_eq!(choice.name(), "external");Trait Implementations§
Source§impl Clone for MaskDecoderChoice
impl Clone for MaskDecoderChoice
Source§impl Debug for MaskDecoderChoice
impl Debug for MaskDecoderChoice
Source§impl Default for MaskDecoderChoice
impl Default for MaskDecoderChoice
Source§impl<'de> Deserialize<'de> for MaskDecoderChoice
impl<'de> Deserialize<'de> for MaskDecoderChoice
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MaskDecoderChoice
Source§impl PartialEq for MaskDecoderChoice
impl PartialEq for MaskDecoderChoice
Source§impl Serialize for MaskDecoderChoice
impl Serialize for MaskDecoderChoice
impl StructuralPartialEq for MaskDecoderChoice
Auto Trait Implementations§
impl Forget for MaskDecoderChoice
impl Freeze for MaskDecoderChoice
impl Move for MaskDecoderChoice
impl RefUnwindSafe for MaskDecoderChoice
impl Send for MaskDecoderChoicewhere
RawVecInner: Send,
impl Sync for MaskDecoderChoicewhere
RawVecInner: Sync,
impl Unpin for MaskDecoderChoice
impl UnsafeUnpin for MaskDecoderChoicewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for MaskDecoderChoicewhere
RawVecInner: UnwindSafe,
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
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
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> ⓘ
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().impl<T> Scalar for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.