Is there any way to convert bounding boxes to polygons, for an instance segmentation model?

I think a similar question may have been asked before, but I couldn’t find an answer.

So I’m currently labeling some objects that are basically perfect squares. It’s time-consuming (and also inaccurate) to manually draw squares using the polygon tool, and it’s much faster to draw bounding boxes instead (just because they are automatically squares). Is there any way to convert these bounding boxes to polygons compatible with the instance segmentation model? (note: I’m looking to segment these squares and not anything inside the square, i.e. not trying to do object detection inside the square).

Thanks!

Yes, you can definitely convert bounding boxes to polygons using Roboflow’s Smart Polygon feature. This feature is especially helpful when using Label-Assist to automate your labels. It removes the initial labeling step and lets you focus on refining the labels by converting them to Smart Polygons [source].

You can also use the Smart Polygon feature to convert bounding box annotations into polygon annotations. To do this, right-click any bounding box then select Convert to Smart Polygon [source].

If you have a dataset annotated with bounding boxes and want to convert it into an instance segmentation dataset, you can use SAM standalone because the model can process existing bounding boxes. You would need to loop over the bounding boxes for each image, querying SAM for each one separately to generate an instance segmentation mask. Then, save the resulting masks and annotations [source].

Remember, polygons are more precise than bounding boxes and can often improve model accuracy when used instead of bounding boxes for object detection models [source].

I hope this helps! Let me know if you have any other questions.


Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, knowledge base, and previous forum responses. If you find this to be a helpful answer, please mark it as the solution using the checkbox icon below. If this doesn’t solve your issue, please follow up with what you’ve tried/why, and the community will continue to chime in as usual.

Hello, thanks.

This works and all, but I’m actually just interested in creating a PERFECT SQUARE polygon label that just happens to have the shape of a bounding box. Smart polygon tries to do some inference on the stuff inside the square, resulting in a weirdly-shaped polygon. Any way to do this?

Thanks again

Hi @Hummus_Akemi

Have you tried using the bounding box tool for your instance segmentation project?

A post was split to a new topic: Exporting SAM results in COCO format