supervisely 6.73.234__py3-none-any.whl → 6.73.235__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ from typing import List
7
7
  import cv2
8
8
  import numpy as np
9
9
 
10
+
10
11
  class HiddenCocoPrints:
11
12
  def __enter__(self):
12
13
  self._original_stdout = sys.stdout
@@ -34,12 +35,13 @@ from supervisely import (
34
35
  logger,
35
36
  )
36
37
  from supervisely.convert.image.image_converter import ImageConverter
38
+ from supervisely.convert.image.image_helper import validate_image_bounds
37
39
  from supervisely.geometry.graph import KeypointsTemplate
38
40
  from supervisely.imaging.color import generate_rgb
39
- from supervisely.convert.image.image_helper import validate_image_bounds
40
41
 
41
42
  conflict_classes = []
42
43
 
44
+
43
45
  # COCO Convert funcs
44
46
  def create_supervisely_annotation(
45
47
  item: ImageConverter.Item,
@@ -53,21 +55,29 @@ def create_supervisely_annotation(
53
55
  name_cat_id_map = coco_category_to_class_name(coco_categories)
54
56
  renamed_classes = {} if renamed_classes is None else renamed_classes
55
57
  renamed_tags = {} if renamed_tags is None else renamed_tags
56
- for object in item.ann_data:
57
- caption = object.get("caption")
58
+ for coco_data in item.ann_data:
59
+ caption = coco_data.get("caption")
58
60
  if caption is not None:
59
61
  tag_name = renamed_tags.get("caption", "caption")
60
62
  imag_tags.append(Tag(meta.get_tag_meta(tag_name), caption))
61
- category_id = object.get("category_id")
63
+ category_id = coco_data.get("category_id")
62
64
  if category_id is None:
63
65
  continue
64
66
  obj_class_name = name_cat_id_map.get(category_id)
65
67
  if obj_class_name is None:
66
- logger.warn(f"Category with id {category_id} not found in categories list")
68
+ logger.warning(f"Category with id {category_id} not found in categories list")
67
69
  continue
68
70
  renamed_class_name = renamed_classes.get(obj_class_name, obj_class_name)
69
71
  key = None
70
- segm = object.get("segmentation")
72
+
73
+ segm = coco_data.get("segmentation")
74
+ keypoints = coco_data.get("keypoints")
75
+ bbox = coco_data.get("bbox")
76
+
77
+ if len([f for f in (segm, keypoints, bbox) if f]) > 1:
78
+ # create a binding key if more than one of the following fields are present
79
+ key = uuid.uuid4().hex
80
+
71
81
  curr_labels = []
72
82
  if segm is not None and len(segm) > 0:
73
83
  obj_class_polygon = meta.get_obj_class(renamed_class_name)
@@ -75,30 +85,24 @@ def create_supervisely_annotation(
75
85
  if obj_class_name not in conflict_classes:
76
86
  geometry_name = obj_class_polygon.geometry_type.geometry_name().capitalize()
77
87
  conflict_classes.append(obj_class_name)
78
- logger.warn(
88
+ logger.warning(
79
89
  "Conflict in class geometry type: "
80
90
  f"object class '{obj_class_name}' (category ID: {category_id}) "
81
91
  f"has type '{geometry_name}', but expected type is 'Polygon'."
82
92
  )
83
93
  continue
84
94
  if type(segm) is dict:
85
- polygons = convert_rle_mask_to_polygon(object)
95
+ polygons = convert_rle_mask_to_polygon(coco_data)
86
96
  for polygon in polygons:
87
- figure = polygon
88
- key = uuid.uuid4().hex
89
- label = Label(figure, obj_class_polygon, binding_key=key)
90
- curr_labels.append(label)
91
- elif type(segm) is list and object["segmentation"]:
92
- figures = convert_polygon_vertices(object, item.shape)
93
- for figure in figures:
94
- key = uuid.uuid4().hex
95
- label = Label(figure, obj_class_polygon, binding_key=key)
96
- curr_labels.append(label)
97
+ curr_labels.append(Label(polygon, obj_class_polygon, binding_key=key))
98
+ elif type(segm) is list and coco_data["segmentation"]:
99
+ polygons = convert_polygon_vertices(coco_data, item.shape)
100
+ for polygon in polygons:
101
+ curr_labels.append(Label(polygon, obj_class_polygon, binding_key=key))
97
102
 
98
- keypoints = object.get("keypoints")
99
103
  if keypoints is not None:
100
104
  obj_class_keypoints = meta.get_obj_class(renamed_class_name)
101
- keypoints = list(get_coords(object["keypoints"]))
105
+ keypoints = list(get_coords(keypoints))
102
106
  coco_categorie, keypoint_names = None, None
103
107
  for cat in coco_categories:
104
108
  if cat["id"] == category_id and cat["supercategory"] == obj_class_name:
@@ -116,11 +120,10 @@ def create_supervisely_annotation(
116
120
  node = Node(label=keypoint_name, row=row, col=col) # , disabled=v)
117
121
  nodes.append(node)
118
122
  if len(nodes) != 0:
119
- key = uuid.uuid4().hex
120
123
  label = Label(GraphNodes(nodes), obj_class_keypoints, binding_key=key)
121
124
  curr_labels.append(label)
122
125
  labels.extend(curr_labels)
123
- bbox = object.get("bbox")
126
+
124
127
  if bbox is not None and len(bbox) == 4:
125
128
  if not obj_class_name.endswith("bbox"):
126
129
  obj_class_name = add_tail(obj_class_name, "bbox")
@@ -130,24 +133,15 @@ def create_supervisely_annotation(
130
133
  if obj_class_name not in conflict_classes:
131
134
  geometry_name = obj_class_rectangle.geometry_type.geometry_name().capitalize()
132
135
  conflict_classes.append(obj_class_name)
133
- logger.warn(
136
+ logger.warning(
134
137
  "Conflict in class geometry type: "
135
138
  f"object class '{obj_class_name}' (category ID: {category_id}) "
136
139
  f"has type '{geometry_name}', but expected type is 'Rectangle'."
137
140
  )
138
141
  continue
139
- if len(curr_labels) > 1:
140
- for label in curr_labels:
141
- bbox = label.geometry.to_bbox()
142
- labels.append(Label(bbox, obj_class_rectangle, binding_key=label.binding_key))
143
- else:
144
- if len(curr_labels) == 1:
145
- key = curr_labels[0].binding_key
146
- x, y, w, h = bbox
147
- rectangle = Label(
148
- Rectangle(y, x, y + h, x + w), obj_class_rectangle, binding_key=key
149
- )
150
- labels.append(rectangle)
142
+ x, y, w, h = bbox
143
+ geometry = Rectangle(y, x, y + h, x + w)
144
+ labels.append(Label(geometry, obj_class_rectangle, binding_key=key))
151
145
  labels = validate_image_bounds(labels, Rectangle.from_size(item.shape))
152
146
  return Annotation(item.shape, labels=labels, img_tags=imag_tags)
153
147
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supervisely
3
- Version: 6.73.234
3
+ Version: 6.73.235
4
4
  Summary: Supervisely Python SDK.
5
5
  Home-page: https://github.com/supervisely/supervisely
6
6
  Author: Supervisely
@@ -565,7 +565,7 @@ supervisely/convert/image/cityscapes/cityscapes_helper.py,sha256=in5nR7__q_u5dCk
565
565
  supervisely/convert/image/coco/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
566
566
  supervisely/convert/image/coco/coco_anntotation_converter.py,sha256=79rhAy_nkudxEgJDLW0BziUz808-fSqTOnlUeN-kvn8,6603
567
567
  supervisely/convert/image/coco/coco_converter.py,sha256=7czTd4I1we_HxEc9diQiXPC2pXAtnoqSnFSVCtNOmP4,5431
568
- supervisely/convert/image/coco/coco_helper.py,sha256=lRr9TcqRVphF_Hlw37-vgJClJBQ-THmCW5xHPYhkxPg,13340
568
+ supervisely/convert/image/coco/coco_helper.py,sha256=rVgorzdw9Um1CN7X0hJmJn2YIwLu9i-_KKI8yDV2h0E,12934
569
569
  supervisely/convert/image/csv/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
570
570
  supervisely/convert/image/csv/csv_converter.py,sha256=iLyc2PAVtlsAq7blnGH4iS1_D7Ai6-4UsdI_RlDVB9Q,11677
571
571
  supervisely/convert/image/csv/csv_helper.py,sha256=-nR192IfMU0vTlNRoKXu5FS6tTs9fENqySyeKKyemRs,8409
@@ -997,9 +997,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
997
997
  supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
998
998
  supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
999
999
  supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
1000
- supervisely-6.73.234.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1001
- supervisely-6.73.234.dist-info/METADATA,sha256=r4mn1H6-TvF7ah1u4bgMSQ5xi4opQMEteUBMfPwPTlM,33150
1002
- supervisely-6.73.234.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
1003
- supervisely-6.73.234.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1004
- supervisely-6.73.234.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1005
- supervisely-6.73.234.dist-info/RECORD,,
1000
+ supervisely-6.73.235.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1001
+ supervisely-6.73.235.dist-info/METADATA,sha256=lxD3ijwTaAh60gS-isykQBCZItRRA7bxjEwF6hMe1lA,33150
1002
+ supervisely-6.73.235.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
1003
+ supervisely-6.73.235.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1004
+ supervisely-6.73.235.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1005
+ supervisely-6.73.235.dist-info/RECORD,,