pythondeep-learningcomputer-visionimage-segmentation

How to autoselect a result from a list


This is the output of my Segment Anything Model: enter image description here

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)
)

enter image description here

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?


Solution

  • Merge the output of segment anything with grounding dino to get the car contour. and remove the other parts of the mask.