This is the output of my Segment Anything Model:
These are the segmentation results:
masks = [
mask['segmentation']
for mask
in sorted(sam_result, key=lambda x: x['area'], reverse=True)
]
sv.plot_images_grid(
images=masks,
grid_size=(8, int(len(masks) / 8)),
size=(16, 16)
)
The second segmentation in the list is what I want. My goal is to use that to erase out the background and just maintaing the car.
However, I want to do this automatically and while I can automate the process, the caveat is that I will have cars of different shapes. How do I automatically segment out the entirety of the car? How to go about this?
Merge the output of segment anything with grounding dino to get the car contour. and remove the other parts of the mask.