Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precision annotation for bounding boxes, using SAM or SAM2 #8326

Open
2 tasks done
Youho99 opened this issue Aug 21, 2024 · 5 comments
Open
2 tasks done

Precision annotation for bounding boxes, using SAM or SAM2 #8326

Youho99 opened this issue Aug 21, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@Youho99
Copy link

Youho99 commented Aug 21, 2024

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

Is your feature request related to a problem? Please describe.

Today, when we want to annotate objects precisely with bounding boxes, it is necessary to zoom in on the object to be almost pixel-perfect, especially for small objects.

This is extremely time-consuming.

The idea of ​​this feature is to be able to annotate quickly and precisely with bounding boxes.

I've already proposed this feature on #8243 and #8231

Describe the solution you'd like

The idea is to make an imprecise bounding box around the object to be annotated. The bounding box is sent to the SAM or SAM2 model, which segments the main object from the bounding box it receives. Finally, the precise bounding box is recreated by taking the extremum coordinates at the top, left, bottom, right.

This would allow very quick and precise annotating, without having to zoom in on the image (very useful for precise annotation of small objects for example).

Describe alternatives you've considered

In my free time, I made a python script using this logic with SAM to make precision annotation, taking as input an annotation json (COCO format I think) and which output a json in the same format, with the precise bounding boxes recalculated.

I could make it available to you if necessary.

Additional context

Many other ideas can arise from this idea, such as:

  • Automatically correct the annotations of an imprecisely annotated dataset (whose bounding boxes are larger than the object). This dataset can come from the internet for example, as you can find plenty of them on Roboflow.

  • Quickly and roughly annotate a few objects (without correcting the precision), train a model which will be poorly performing in its metrics, but which will be capable of producing imprecise bounding boxes (larger than the object), and finally automatically correct the precision of these automatically generated bounding boxes. This would enable accurate self-labeling models to be obtained in a short time.

@Youho99 Youho99 added the enhancement New feature or request label Aug 21, 2024
@bsekachev
Copy link
Member

Hello,

  1. Annotate masks/polygons using SAM/SAM2 (e.g. including bounding box as input, what was recently supported in Segment Anything: supported bounding box input #8270)
  2. Run shapes converter to convert annotated shapes to rectangles (on app.cvat.ai) or postprocess final polygons with your own scripts

@Youho99
Copy link
Author

Youho99 commented Aug 21, 2024

@bsekachev Thanks for your message !

Great, I didn't know about this possibility.

I was thinking of a direct solution instead, but that could also do the trick initially.

@Youho99
Copy link
Author

Youho99 commented Aug 21, 2024

So, reconsidering the feature that I am proposing, with the "shape converters" part, it would be interesting to have the "rectangle to SAM masks" option. Because currently, the "rectangle to mask" option creates a square mask, like the bbox...

This could make it possible to process and make accurate datasets with imprecise annotations in one go.

@Youho99
Copy link
Author

Youho99 commented Aug 21, 2024

One last point: Is the behavior you cited reproducible with the Dockerized version?

@bsekachev
Copy link
Member

I was thinking of a direct solution instead, but that could also do the trick initially.

Sure, that just was workaround proposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants