Skip to content

Commit 089c0ea

Browse files
Add bounding box scaling note (#24884)
* Add scale comment * Update docs/machine-learning/tutorials/object-detection-model-builder.md Thanks Co-authored-by: Youssef Victor <[email protected]> * Update docs/machine-learning/tutorials/object-detection-model-builder.md Co-authored-by: Youssef Victor <[email protected]> * Update docs/machine-learning/tutorials/object-detection-model-builder.md Co-authored-by: Youssef Victor <[email protected]> * Update docs/machine-learning/tutorials/object-detection-model-builder.md Co-authored-by: Youssef Victor <[email protected]> * Update based on feedback * Fixing build issue * Updates based on feedback * Making optional more visible Co-authored-by: Youssef Victor <[email protected]>
1 parent ac52aa8 commit 089c0ea

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/machine-learning/tutorials/object-detection-model-builder.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,23 @@ Two projects are created as a result of the training process.
255255
Top: 89.453415, Left: 481.95343, Right: 724.8073, Bottom: 388.32385, Label: Stop-Sign, Score: 0.99539465
256256
```
257257

258+
> [!NOTE]
259+
> **(Optional)** The bounding box coordinates are normalized for a width of 800 pixels and a height of 600 pixels. To scale the bounding box coordinates for your image in further post-processing, you need to:
260+
>
261+
> 1. Multiply the top and bottom coordinates by the original image height, and multiply the left and right coordinates by the original image width.
262+
> 1. Divide the top and bottom coordinates by 600, and divide the left and right coordinates by 800.
263+
>
264+
> For example, given the original image dimensions,`actualImageHeight` and `actualImageWidth`, and a `ModelOutput` called `prediction`, the following code snippet shows how to scale the `BoundingBox` coordinates:
265+
>
266+
> ```csharp
267+
> var top = originalImageHeight * prediction.Top / 600;
268+
> var bottom = originalImageHeight * prediction.Bottom / 600;
269+
> var left = originalImageWidth * prediction.Left / 800;
270+
> var right = originalImageWidth * prediction.Right / 800;
271+
> ```
272+
>
273+
> An image may have more than one bounding box, so the same process needs to be applied to each of the bounding boxes in the image.
274+
258275
Congratulations! You've successfully built a machine learning model to detect stop signs in images using Model Builder. You can find the source code for this tutorial at the [dotnet/machinelearning-samples](https://github.com/dotnet/machinelearning-samples/tree/main/samples/modelbuilder/ObjectDetection_StopSigns) GitHub repository.
259276
260277
## Additional resources

0 commit comments

Comments
 (0)