1
1
from typing import Dict , Any , Union
2
2
from pathlib import Path
3
3
import os
4
+ import warnings
4
5
5
- from labelbox . data .annotation_types .collection import LabelCollection , LabelGenerator
6
- from labelbox . data .serialization .coco .instance_dataset import CocoInstanceDataset
7
- from labelbox . data .serialization .coco .panoptic_dataset import CocoPanopticDataset
6
+ from .. .annotation_types .collection import LabelCollection , LabelGenerator
7
+ from .. .serialization .coco .instance_dataset import CocoInstanceDataset
8
+ from .. .serialization .coco .panoptic_dataset import CocoPanopticDataset
8
9
9
10
10
11
def create_path_if_not_exists (path : Union [Path , str ],
@@ -28,7 +29,7 @@ def validate_path(path: Union[Path, str], name: str):
28
29
29
30
class COCOConverter :
30
31
"""
31
- Class for convertering between coco and labelbox formats
32
+ Class for converting between coco and labelbox formats
32
33
Note that this class is only compatible with image data.
33
34
34
35
Subclasses are currently ignored.
@@ -55,6 +56,12 @@ def serialize_instances(labels: LabelCollection,
55
56
Returns:
56
57
A dictionary containing labels in the coco object format.
57
58
"""
59
+
60
+ warnings .warn (
61
+ "You are currently utilizing COCOconverter for this action, which will be deprecated in a later release." ,
62
+ DeprecationWarning ,
63
+ stacklevel = 2 )
64
+
58
65
image_root = create_path_if_not_exists (image_root , ignore_existing_data )
59
66
return CocoInstanceDataset .from_common (labels = labels ,
60
67
image_root = image_root ,
@@ -85,6 +92,12 @@ def serialize_panoptic(labels: LabelCollection,
85
92
Returns:
86
93
A dictionary containing labels in the coco panoptic format.
87
94
"""
95
+
96
+ warnings .warn (
97
+ "You are currently utilizing COCOconverter for this action, which will be deprecated in a later release." ,
98
+ DeprecationWarning ,
99
+ stacklevel = 2 )
100
+
88
101
image_root = create_path_if_not_exists (image_root , ignore_existing_data )
89
102
mask_root = create_path_if_not_exists (mask_root , ignore_existing_data )
90
103
return CocoPanopticDataset .from_common (labels = labels ,
@@ -107,6 +120,12 @@ def deserialize_panoptic(json_data: Dict[str, Any], image_root: Union[Path,
107
120
Returns:
108
121
LabelGenerator
109
122
"""
123
+
124
+ warnings .warn (
125
+ "You are currently utilizing COCOconverter for this action, which will be deprecated in a later release." ,
126
+ DeprecationWarning ,
127
+ stacklevel = 2 )
128
+
110
129
image_root = validate_path (image_root , 'image_root' )
111
130
mask_root = validate_path (mask_root , 'mask_root' )
112
131
objs = CocoPanopticDataset (** json_data )
@@ -125,6 +144,12 @@ def deserialize_instances(json_data: Dict[str, Any],
125
144
Returns:
126
145
LabelGenerator
127
146
"""
147
+
148
+ warnings .warn (
149
+ "You are currently utilizing COCOconverter for this action, which will be deprecated in a later release." ,
150
+ DeprecationWarning ,
151
+ stacklevel = 2 )
152
+
128
153
image_root = validate_path (image_root , 'image_root' )
129
154
objs = CocoInstanceDataset (** json_data )
130
155
gen = objs .to_common (image_root )
0 commit comments