Struct segment_anything_rs::SegmentAnything
source · 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
.
Examples found in repository?
More examples
examples/segment-anything.rs (line 4)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
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)
.unwrap()
.add_goal_point(x, y),
)
.unwrap();
images.save("out.png").unwrap();
}
sourcepub fn segment_from_points(
&self,
settings: SegmentAnythingInferenceSettings
) -> Result<DynamicImage>
pub fn segment_from_points( &self, settings: SegmentAnythingInferenceSettings ) -> Result<DynamicImage>
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)
.unwrap()
.add_goal_point(x, y),
)
.unwrap();
images.save("out.png").unwrap();
Examples found in repository?
examples/segment-anything.rs (lines 9-13)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() {
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)
.unwrap()
.add_goal_point(x, y),
)
.unwrap();
images.save("out.png").unwrap();
}
sourcepub fn segment_everything(
&self,
image: DynamicImage
) -> Result<Vec<DynamicImage>>
pub fn segment_everything( &self, image: DynamicImage ) -> Result<Vec<DynamicImage>>
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 !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