Adding Padding to Prediction

I’m currently creating a workflow to do segmentation on an image of a card and I would like to be able to add some padding to the prediction because sometimes the model cuts off the edges of the card.

I attempted to use the Detection Offset block by adding 25% to the width and height of the detection in hopes that it would add 25% padding around the prediction. However, when I add a polygon visualization afterwards nothing is changed.

Not sure what I’m doing wrong here and would appreciate any help

  • **Project Type: Workflow with segmentation model
  • **Operating System & Browser: MacOS 15.1 , Chrome

Workflow with the Detection Offset configuration

As you can see in the polygon visualization image the prediction has no extra padding and some of the edges are slightly cut off.

Took a look into the issue, here’s what is happening:

The instance segmentation model returns two points of data about the detected objects: the bounding boxes and the polygon points.

The Detections Offset block currently only works on bounding boxes, but not polygons. So only the bounding box data is affected. You’d need to use a Bounding Box visualization block will see the offset boxes, but the polygon annotations are unaffected.

Thanks for taking a look and for the explanation of what’s happening.

I tested out using the Bounding Box Visualization block and was able to see the padding applied up to a certain amount. If I tried increasing the width and height too much it didn’t show up.

Since the Detection Offset only applies to Bounding boxes is there a good way to convert the the polygon into a box that matches the cards corners in the Workflow? If not, no worries I may need to start writing code for a more custom workflow.

As you can see here, the offset worked on the bounding box, but I want to correct the perspective of the card using the polygon semgentation while adding a little bit of additional padding to make sure the edges are not cut off.

Hi @cgray9 ,

Within 0.37.0 release of inference we are adding extra parameter called Scale Ratio to dynamic zones block, this should resolve this problem.

Grzegorz

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.