Skip to content

Commit 172877a

Browse files
committed
Fix accidental changes, rearrange utils, rename methods
1 parent a91fc1e commit 172877a

File tree

7 files changed

+15
-19
lines changed

7 files changed

+15
-19
lines changed

docs/changelog.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ with csv_sink:
176176

177177
- Added [#819](https://github.com/roboflow/supervision/pull/819): [`sv.JSONSink`](/0.19.0/detection/tools/save_detections/#supervision.detection.tools.csv_sink.JSONSink) allowing for the straightforward saving of image, video, or stream inference results in a `.json` file.
178178

179-
````python
180-
181179
```python
182180
import supervision as sv
183181
from ultralytics import YOLO
@@ -191,7 +189,7 @@ with json_sink:
191189
result = model(frame)[0]
192190
detections = sv.Detections.from_ultralytics(result)
193191
json_sink.append(detections, custom_data={<CUSTOM_LABEL>:<CUSTOM_DATA>})
194-
````
192+
```
195193

196194
- Added [#847](https://github.com/roboflow/supervision/pull/847): [`sv.mask_iou_batch`](/0.19.0/detection/utils/#supervision.detection.utils.mask_iou_batch) allowing to compute Intersection over Union (IoU) of two sets of masks.
197195

docs/deprecated.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ status: deprecated
55

66
These features are phased out due to better alternatives or potential issues in future versions. Deprecated functionalities are supported for **three subsequent releases**, providing time for users to transition to updated methods.
77

8-
- [`Detections.from_froboflow`](detection/core.md/#supervision.detection.core.Detections.from_roboflow) is deprecated and will be removed in `supervision-0.22.0`. Use [`Detections.from_inference`](detection/core.md/#supervision.detection.core.Detections.from_inference) instead.
8+
- [`Detections.from_roboflow`](detection/core.md/#supervision.detection.core.Detections.from_roboflow) is deprecated and will be removed in `supervision-0.22.0`. Use [`Detections.from_inference`](detection/core.md/#supervision.detection.core.Detections.from_inference) instead.
99
- The method `Color.white()` is deprecated and will be removed in `supervision-0.22.0`. Use the constant `Color.WHITE` instead.
1010
- The method `Color.black()` is deprecated and will be removed in `supervision-0.22.0`. Use the constant `Color.BLACK` instead.
1111
- The method `Color.red()` is deprecated and will be removed in `supervision-0.22.0`. Use the constant `Color.RED` instead.

supervision/dataset/formats/pascal_voc.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ def load_pascal_voc_annotations(
183183
)
184184
annotations[image_path] = annotation
185185

186-
# TODO: classes are wrong
187-
188186
return classes, image_paths, annotations
189187

190188

supervision/dataset/formats/yolo.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _extract_class_names(file_path: str) -> List[str]:
6868
return names
6969

7070

71-
def image_name_to_annotation_name(image_name: str) -> str:
71+
def _image_name_to_annotation_name(image_name: str) -> str:
7272
base_name, _ = os.path.splitext(image_name)
7373
return base_name + ".txt"
7474

@@ -242,12 +242,6 @@ def detections_to_yolo_annotations(
242242
return annotation
243243

244244

245-
def save_data_yaml(data_yaml_path: str, classes: List[str]) -> None:
246-
data = {"nc": len(classes), "names": classes}
247-
Path(data_yaml_path).parent.mkdir(parents=True, exist_ok=True)
248-
save_yaml_file(data=data, file_path=data_yaml_path)
249-
250-
251245
def save_yolo_annotations(
252246
dataset: "DetectionDataset",
253247
annotations_directory_path: str,
@@ -258,7 +252,7 @@ def save_yolo_annotations(
258252
Path(annotations_directory_path).mkdir(parents=True, exist_ok=True)
259253
for image_path, image, annotation in dataset:
260254
image_name = Path(image_path).name
261-
yolo_annotations_name = image_name_to_annotation_name(image_name=image_name)
255+
yolo_annotations_name = _image_name_to_annotation_name(image_name=image_name)
262256
yolo_annotations_path = os.path.join(
263257
annotations_directory_path, yolo_annotations_name
264258
)
@@ -270,3 +264,9 @@ def save_yolo_annotations(
270264
approximation_percentage=approximation_percentage,
271265
)
272266
save_text_file(lines=lines, file_path=yolo_annotations_path)
267+
268+
269+
def save_data_yaml(data_yaml_path: str, classes: List[str]) -> None:
270+
data = {"nc": len(classes), "names": classes}
271+
Path(data_yaml_path).parent.mkdir(parents=True, exist_ok=True)
272+
save_yaml_file(data=data, file_path=data_yaml_path)

supervision/draw/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ def calculate_optimal_text_scale(resolution_wh: Tuple[int, int]) -> float:
295295
Calculate font scale based on the resolution of an image.
296296
297297
Parameters:
298-
resolution_wh (Tuple[int, int]): A tuple representing the width and height
299-
of the image.
298+
resolution_wh (Tuple[int, int]): A tuple representing the width and height
299+
of the image.
300300
301301
Returns:
302302
float: The calculated font scale factor.

test/dataset/formats/test_yolo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import pytest
66

77
from supervision.dataset.formats.yolo import (
8+
_image_name_to_annotation_name,
89
_with_mask,
9-
image_name_to_annotation_name,
1010
object_to_yolo,
1111
yolo_annotations_to_detections,
1212
)
@@ -205,7 +205,7 @@ def test_image_name_to_annotation_name(
205205
image_name: str, expected_result: Optional[str], exception: Exception
206206
) -> None:
207207
with exception:
208-
result = image_name_to_annotation_name(image_name=image_name)
208+
result = _image_name_to_annotation_name(image_name=image_name)
209209
assert result == expected_result
210210

211211

test/dataset/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[
1414
(
1515
[],
16-
DetectionDataset(classes=[], images=[], annotations={}),
16+
DetectionDataset(classes=[], images={}, annotations={}),
1717
DoesNotRaise(),
1818
), # empty dataset list
1919
(

0 commit comments

Comments
 (0)