docs: 📝 RichLabelAnnotator documentation added into docs and minor var fixes

Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
This commit is contained in:
Onuralp SEZER 2024-05-15 18:35:36 +03:00
parent df4a6f857c
commit 24d1840ea1
No known key found for this signature in database
GPG Key ID: CF0835DFDF14CA38
3 changed files with 40 additions and 2 deletions

View File

@ -285,6 +285,37 @@ status: new
</div>
=== "RichLabel"
```python
import supervision as sv
image = ...
detections = sv.Detections(...)
labels = [
f"{class_name} {confidence:.2f}"
for class_name, confidence
in zip(detections['class_name'], detections.confidence)
]
rich_label_annotator = sv.RichLabelAnnotator(
font_path=".../font.ttf",
text_position=sv.Position.CENTER
)
annotated_frame = label_annotator.annotate(
scene=image.copy(),
detections=detections,
labels=labels
)
```
<div class="result" markdown>
![label-annotator-example](https://media.roboflow.com/supervision-annotator-examples/label-annotator-example-purple.png){ align=center width="800" }
</div>
=== "Crop"
```python
@ -492,6 +523,12 @@ status: new
:::supervision.annotators.core.LabelAnnotator
<div class="md-typeset">
<h2><a href="#supervision.annotators.core.RichLabelAnnotator">RichLabelAnnotator</a></h2>
</div>
:::supervision.annotators.core.RichLabelAnnotator
<div class="md-typeset">
<h2><a href="#supervision.annotators.core.BlurAnnotator">BlurAnnotator</a></h2>
</div>

View File

@ -18,6 +18,7 @@ from supervision.annotators.core import (
HaloAnnotator,
HeatMapAnnotator,
LabelAnnotator,
RichLabelAnnotator,
MaskAnnotator,
OrientedBoxAnnotator,
PercentageBarAnnotator,

View File

@ -1177,7 +1177,7 @@ class RichLabelAnnotator:
Example:
```python
import supervision as sv
import supervision as sv
image = ...
detections = sv.Detections(...)
@ -1188,7 +1188,7 @@ class RichLabelAnnotator:
in zip(detections['class_name'], detections.confidence)
]
label_annotator = sv.RichLabelAnnotator(font_path="path/to/font.ttf")
rich_label_annotator = sv.RichLabelAnnotator(font_path="path/to/font.ttf")
annotated_frame = label_annotator.annotate(
scene=image.copy(),
detections=detections,