pub struct SegmentAnything { /* private fields */ }
Expand description
The segment anything model.
Implementations§
Source§impl SegmentAnything
impl SegmentAnything
Sourcepub fn builder() -> SegmentAnythingBuilder
pub fn builder() -> SegmentAnythingBuilder
Creates a new SegmentAnythingBuilder
.
Sourcepub fn segment_from_points(
&self,
settings: SegmentAnythingInferenceSettings,
) -> Result<DynamicImage, SegmentAnythingInferenceError>
pub fn segment_from_points( &self, settings: SegmentAnythingInferenceSettings, ) -> Result<DynamicImage, SegmentAnythingInferenceError>
Segment an image from a list of points. Returns a DynamicImage
mask.
§Example
use segment_anything_rs::*;
let model = SegmentAnything::builder().build().unwrap();
let image = image::open("examples/landscape.jpg").unwrap();
let x = image.width() / 2;
let y = image.height() / 4;
let images = model
.segment_from_points(SegmentAnythingInferenceSettings::new(image).add_goal_point(x, y))
.unwrap();
images.save("out.png").unwrap();
Sourcepub fn segment_everything(
&self,
image: DynamicImage,
) -> Result<Vec<DynamicImage>, SegmentAnythingInferenceError>
pub fn segment_everything( &self, image: DynamicImage, ) -> Result<Vec<DynamicImage>, SegmentAnythingInferenceError>
Segment everything in an image. Returns a list of DynamicImage
masks.
§Example
use segment_anything_rs::*;
let model = SegmentAnything::builder().build().unwrap();
let image = image::open("examples/landscape.jpg").unwrap();
let images = model.segment_everything(image).unwrap();
for (i, img) in images.iter().enumerate() {
img.save(&format!("{}.png", i)).unwrap();
}
Auto Trait Implementations§
impl Freeze for SegmentAnything
impl !RefUnwindSafe for SegmentAnything
impl Send for SegmentAnything
impl Sync for SegmentAnything
impl Unpin for SegmentAnything
impl !UnwindSafe for SegmentAnything
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> 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>
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