Add visualize_image_annotations function (#18430)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
This commit is contained in:
parent
7f1a50e893
commit
990424cb63
3 changed files with 73 additions and 0 deletions
|
|
@ -46,6 +46,26 @@ This function does not return any value. For further details on how the function
|
|||
- [See the reference section for `annotator.auto_annotate`](../reference/data/annotator.md#ultralytics.data.annotator.auto_annotate) for more insight on how the function operates.
|
||||
- Use in combination with the [function `segments2boxes`](#convert-segments-to-bounding-boxes) to generate object detection bounding boxes as well
|
||||
|
||||
### Visualize Dataset Annotations
|
||||
|
||||
This function visualizes YOLO annotations on an image before training, helping to identify and correct any wrong annotations that could lead to incorrect detection results. It draws bounding boxes, labels objects with class names, and adjusts text color based on the background's luminance for better readability.
|
||||
|
||||
```{ .py .annotate }
|
||||
from ultralytics.data.utils import visualize_image_annotations
|
||||
|
||||
label_map = { # Define the label map with all annotated class labels.
|
||||
0: "person",
|
||||
1: "car",
|
||||
}
|
||||
|
||||
# Visualize
|
||||
visualize_image_annotations(
|
||||
"path/to/image.jpg", # Input image path.
|
||||
"path/to/annotations.txt", # Annotation file path for the image.
|
||||
label_map,
|
||||
)
|
||||
```
|
||||
|
||||
### Convert Segmentation Masks into YOLO Format
|
||||
|
||||

|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue