# Adding Padding to Prediction

**URL:** https://discuss.roboflow.com/t/adding-padding-to-prediction/8523
**Category:** 🤝  Community Help
**Tags:** segmentation
**Created:** [February 6, 2025, 5:19am UTC](https://discuss.roboflow.com/t/adding-padding-to-prediction/8523 "2025-02-06T05:19:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cgray9](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/cgray9/32/6550_2.png) [@cgray9](https://discuss.roboflow.com/u/cgray9)
#### Post date: [February 6, 2025, 5:19am UTC](https://discuss.roboflow.com/t/adding-padding-to-prediction/8523/1 "2025-02-06T05:19:10Z")

</div>

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

 ![Screenshot 2025-02-06 at 12.12.49 AM](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/9/92c61c90e2f3579d4e91fb37ca403c62b88ef9ef.png)

---

<div class="post-metadata">

### Author: ![cgray9](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/cgray9/32/6550_2.png) [@cgray9](https://discuss.roboflow.com/u/cgray9)
#### Post date: [February 6, 2025, 5:20am UTC](https://discuss.roboflow.com/t/adding-padding-to-prediction/8523/2 "2025-02-06T05:20:51Z")

</div>

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

 ![Screenshot 2025-02-06 at 12.13.42 AM](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/1/1cf2cdce4c60524e1abd5f2825de4ad17902e01d.jpeg)

---

<div class="post-metadata">

### Author: ![Emily](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/emily/32/3014_2.png) [@Emily](https://discuss.roboflow.com/u/Emily)
#### Post date: [February 6, 2025, 4:50pm UTC](https://discuss.roboflow.com/t/adding-padding-to-prediction/8523/3 "2025-02-06T16:50:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![cgray9](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/cgray9/32/6550_2.png) [@cgray9](https://discuss.roboflow.com/u/cgray9)
#### Post date: [February 6, 2025, 6:02pm UTC](https://discuss.roboflow.com/t/adding-padding-to-prediction/8523/4 "2025-02-06T18:02:39Z")

</div>

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.

 ![Screenshot 2025-02-06 at 12.53.36 PM](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/2X/5/5716a22bb6b3cfe3e1dce1b59d1e6d16ec7192c5.jpeg)

---

<div class="post-metadata">

### Author: ![Grzegorz](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/grzegorz/32/2877_2.png) [@Grzegorz](https://discuss.roboflow.com/u/Grzegorz)
#### Post date: [February 7, 2025, 11:48am UTC](https://discuss.roboflow.com/t/adding-padding-to-prediction/8523/5 "2025-02-07T11:48:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex029/uploads/roboflow1/original/1X/bb6edbfa56d0cf2ee603f061e9e09103502cc8cc.png) [@system](https://discuss.roboflow.com/u/system)
#### Post date: [February 25, 2025, 2:59pm UTC](https://discuss.roboflow.com/t/adding-padding-to-prediction/8523/6 "2025-02-25T14:59:27Z")

</div>

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