facebookresearch / sam2

The repository provides code for running inference with the Meta Segment Anything Model 2 (SAM 2), links for downloading the trained model checkpoints, and example notebooks that show how to use the model.
Apache License 2.0
12.37k stars 1.14k forks source link

how to segment the objects without background #82

Open jack-gits opened 3 months ago

jack-gits commented 3 months ago

In my images, there're mobile and others. I just want to segment the mobile from the image.

`

mask_generator = SamAutomaticMaskGenerator( model=sam, points_per_side=32, pred_iou_thresh=0.86, stability_score_thresh=0.92, crop_n_layers=1, crop_n_points_downscale_factor=2, min_mask_region_area=100, # Requires open-cv to run post-processing )

masks = mask_generator.generate(image)

` but some masks only includes the background, such as Mask 1, Mask 2,Mask 5 in blow picture, and some masks includes mobile with background, Mask 6 in below picture. how the only generate the masks with mobile?

10097

Akshat-Vashisht commented 2 days ago

I am facing a similar issue. I am trying to generate masks on the image of a leaf, but whenever there is a single-coloured background (plain white), it takes the background as the original mask rather than the leaf.

The first image should give the leaf in white color (which it isn't giving for some reason) I can elaborate on this if the issue on this thread is looked at.

image

Akshat-Vashisht commented 2 days ago

This was the original image for reference

@jack-gits If you have found any resolution for the same, do let me know DSC05085