pub struct SegmentAnythingInferenceSettings { /* private fields */ }
Expand description
Settings for running inference on SegmentAnything
.
Implementations§
source§impl SegmentAnythingInferenceSettings
impl SegmentAnythingInferenceSettings
sourcepub fn new<I: GenericImageView<Pixel = Rgba<u8>>>(input: I) -> Result<Self>
pub fn new<I: GenericImageView<Pixel = Rgba<u8>>>(input: I) -> Result<Self>
Creates a new SegmentAnythingInferenceSettings
from an image.
Examples found in repository?
examples/segment-anything.rs (line 10)
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 set_threshold(self, threshold: f32) -> Self
pub fn set_threshold(self, threshold: f32) -> Self
Sets the detection threshold for the mask, 0 is the default value.
- A negative values makes the model return a larger mask.
- A positive makes the model return a smaller mask.
sourcepub fn add_goal_point(self, x: impl Into<f64>, y: impl Into<f64>) -> Self
pub fn add_goal_point(self, x: impl Into<f64>, y: impl Into<f64>) -> Self
Add a point to the list of points to segment.
Examples found in repository?
examples/segment-anything.rs (line 12)
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 set_goal_points(self, points: Vec<(f64, f64)>) -> Self
pub fn set_goal_points(self, points: Vec<(f64, f64)>) -> Self
Set the list of points to segment.
sourcepub fn add_avoid_points(self, x: impl Into<f64>, y: impl Into<f64>) -> Self
pub fn add_avoid_points(self, x: impl Into<f64>, y: impl Into<f64>) -> Self
Add a point to the list of points to avoid.
sourcepub fn set_avoid_points(self, points: Vec<(f64, f64)>) -> Self
pub fn set_avoid_points(self, points: Vec<(f64, f64)>) -> Self
Set the list of points to avoid.
Auto Trait Implementations§
impl RefUnwindSafe for SegmentAnythingInferenceSettings
impl Send for SegmentAnythingInferenceSettings
impl Sync for SegmentAnythingInferenceSettings
impl Unpin for SegmentAnythingInferenceSettings
impl UnwindSafe for SegmentAnythingInferenceSettings
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