supervisely 6.73.365__py3-none-any.whl → 6.73.367__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.
- supervisely/annotation/annotation.py +21 -21
- supervisely/annotation/label.py +4 -4
- supervisely/annotation/obj_class.py +9 -5
- supervisely/annotation/obj_class_collection.py +2 -2
- supervisely/annotation/tag.py +2 -2
- supervisely/annotation/tag_collection.py +3 -3
- supervisely/annotation/tag_meta.py +2 -2
- supervisely/annotation/tag_meta_collection.py +2 -2
- supervisely/api/agent_api.py +1 -1
- supervisely/api/annotation_api.py +1 -1
- supervisely/api/dataset_api.py +4 -4
- supervisely/api/entities_collection_api.py +1 -1
- supervisely/api/file_api.py +10 -10
- supervisely/api/image_api.py +18 -14
- supervisely/api/labeling_job_api.py +1 -1
- supervisely/api/labeling_queue_api.py +1 -1
- supervisely/api/module_api.py +6 -6
- supervisely/api/object_class_api.py +1 -1
- supervisely/api/plugin_api.py +1 -1
- supervisely/api/pointcloud/pointcloud_annotation_api.py +1 -1
- supervisely/api/pointcloud/pointcloud_api.py +1 -1
- supervisely/api/pointcloud/pointcloud_episode_annotation_api.py +1 -1
- supervisely/api/pointcloud/pointcloud_episode_api.py +1 -1
- supervisely/api/project_api.py +4 -4
- supervisely/api/remote_storage_api.py +6 -6
- supervisely/api/role_api.py +1 -1
- supervisely/api/storage_api.py +3 -3
- supervisely/api/task_api.py +1 -1
- supervisely/api/team_api.py +1 -1
- supervisely/api/user_api.py +1 -1
- supervisely/api/video/video_annotation_api.py +1 -1
- supervisely/api/video/video_api.py +4 -4
- supervisely/api/volume/volume_annotation_api.py +1 -1
- supervisely/api/volume/volume_api.py +1 -1
- supervisely/api/workspace_api.py +1 -2
- supervisely/app/development/sly-net.sh +2 -2
- supervisely/app/fastapi/index.html +3 -3
- supervisely/app/fastapi/subapp.py +1 -1
- supervisely/aug/aug.py +10 -10
- supervisely/cli/__init__.py +15 -10
- supervisely/geometry/alpha_mask.py +2 -2
- supervisely/geometry/bitmap.py +8 -6
- supervisely/geometry/bitmap_base.py +63 -24
- supervisely/geometry/cuboid.py +97 -50
- supervisely/geometry/cuboid_2d.py +2 -2
- supervisely/geometry/graph.py +4 -4
- supervisely/geometry/mask_3d.py +1 -1
- supervisely/geometry/point.py +63 -24
- supervisely/geometry/point_location.py +2 -2
- supervisely/geometry/polygon.py +2 -2
- supervisely/geometry/polyline.py +32 -40
- supervisely/geometry/rectangle.py +2 -2
- supervisely/geometry/vector_geometry.py +27 -39
- supervisely/io/env.py +3 -2
- supervisely/labeling_jobs/utils.py +5 -5
- supervisely/nn/model/prediction_session.py +2 -2
- supervisely/pointcloud/pointcloud.py +2 -2
- supervisely/pointcloud_annotation/pointcloud_annotation.py +19 -17
- supervisely/pointcloud_annotation/pointcloud_episode_annotation.py +23 -20
- supervisely/pointcloud_annotation/pointcloud_episode_frame.py +18 -12
- supervisely/pointcloud_annotation/pointcloud_episode_frame_collection.py +9 -6
- supervisely/pointcloud_annotation/pointcloud_episode_object_collection.py +7 -3
- supervisely/pointcloud_annotation/pointcloud_episode_tag.py +1 -1
- supervisely/pointcloud_annotation/pointcloud_episode_tag_collection.py +2 -2
- supervisely/pointcloud_annotation/pointcloud_figure.py +1 -1
- supervisely/pointcloud_annotation/pointcloud_object_collection.py +11 -10
- supervisely/pointcloud_annotation/pointcloud_tag.py +5 -4
- supervisely/pointcloud_annotation/pointcloud_tag_collection.py +7 -6
- supervisely/pointcloud_episodes/pointcloud_episodes.py +2 -2
- supervisely/project/download.py +1 -1
- supervisely/project/pointcloud_episode_project.py +1 -2
- supervisely/project/pointcloud_project.py +1 -1
- supervisely/project/project.py +8 -7
- supervisely/project/project_meta.py +2 -2
- supervisely/project/readme_template.md +1 -1
- supervisely/project/upload.py +1 -1
- supervisely/project/video_project.py +1 -1
- supervisely/project/volume_project.py +1 -1
- supervisely/task/progress.py +1 -1
- supervisely/video_annotation/frame.py +2 -2
- supervisely/video_annotation/frame_collection.py +3 -3
- supervisely/video_annotation/video_annotation.py +7 -5
- supervisely/video_annotation/video_figure.py +2 -2
- supervisely/video_annotation/video_object.py +47 -28
- supervisely/video_annotation/video_object_collection.py +15 -8
- supervisely/video_annotation/video_tag.py +2 -2
- supervisely/video_annotation/video_tag_collection.py +5 -5
- supervisely/volume_annotation/volume_figure.py +2 -2
- supervisely/volume_annotation/volume_tag.py +6 -5
- {supervisely-6.73.365.dist-info → supervisely-6.73.367.dist-info}/METADATA +2 -2
- {supervisely-6.73.365.dist-info → supervisely-6.73.367.dist-info}/RECORD +95 -95
- {supervisely-6.73.365.dist-info → supervisely-6.73.367.dist-info}/LICENSE +0 -0
- {supervisely-6.73.365.dist-info → supervisely-6.73.367.dist-info}/WHEEL +0 -0
- {supervisely-6.73.365.dist-info → supervisely-6.73.367.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.365.dist-info → supervisely-6.73.367.dist-info}/top_level.txt +0 -0
supervisely/geometry/point.py
CHANGED
|
@@ -3,16 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
# docs
|
|
5
5
|
from __future__ import annotations
|
|
6
|
-
import cv2
|
|
7
|
-
from typing import List, Tuple, Dict, Optional
|
|
8
|
-
from supervisely.geometry.image_rotator import ImageRotator
|
|
9
6
|
|
|
7
|
+
from typing import Dict, List, Optional, Tuple
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
import cv2
|
|
10
|
+
|
|
11
|
+
from supervisely._utils import unwrap_if_numpy
|
|
12
|
+
from supervisely.geometry.constants import (
|
|
13
|
+
CLASS_ID,
|
|
14
|
+
CREATED_AT,
|
|
15
|
+
ID,
|
|
16
|
+
LABELER_LOGIN,
|
|
17
|
+
UPDATED_AT,
|
|
18
|
+
)
|
|
12
19
|
from supervisely.geometry.geometry import Geometry
|
|
20
|
+
from supervisely.geometry.image_rotator import ImageRotator
|
|
21
|
+
from supervisely.geometry.point_location import PointLocation
|
|
13
22
|
from supervisely.geometry.rectangle import Rectangle
|
|
14
|
-
from supervisely._utils import unwrap_if_numpy
|
|
15
|
-
from supervisely.geometry.constants import LABELER_LOGIN, UPDATED_AT, CREATED_AT, ID, CLASS_ID
|
|
16
23
|
|
|
17
24
|
|
|
18
25
|
class Point(Geometry):
|
|
@@ -44,10 +51,24 @@ class Point(Geometry):
|
|
|
44
51
|
col = 200
|
|
45
52
|
figure = sly.Point(row, col)
|
|
46
53
|
"""
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
|
|
55
|
+
def __init__(
|
|
56
|
+
self,
|
|
57
|
+
row: int,
|
|
58
|
+
col: int,
|
|
59
|
+
sly_id: Optional[int] = None,
|
|
60
|
+
class_id: Optional[int] = None,
|
|
61
|
+
labeler_login: Optional[int] = None,
|
|
62
|
+
updated_at: Optional[str] = None,
|
|
63
|
+
created_at: Optional[str] = None,
|
|
64
|
+
):
|
|
65
|
+
super().__init__(
|
|
66
|
+
sly_id=sly_id,
|
|
67
|
+
class_id=class_id,
|
|
68
|
+
labeler_login=labeler_login,
|
|
69
|
+
updated_at=updated_at,
|
|
70
|
+
created_at=created_at,
|
|
71
|
+
)
|
|
51
72
|
self._row = round(unwrap_if_numpy(row))
|
|
52
73
|
self._col = round(unwrap_if_numpy(col))
|
|
53
74
|
|
|
@@ -84,8 +105,15 @@ class Point(Geometry):
|
|
|
84
105
|
return self._col
|
|
85
106
|
|
|
86
107
|
@classmethod
|
|
87
|
-
def from_point_location(
|
|
88
|
-
|
|
108
|
+
def from_point_location(
|
|
109
|
+
cls,
|
|
110
|
+
pt: PointLocation,
|
|
111
|
+
sly_id: Optional[int] = None,
|
|
112
|
+
class_id: Optional[int] = None,
|
|
113
|
+
labeler_login: Optional[int] = None,
|
|
114
|
+
updated_at: Optional[str] = None,
|
|
115
|
+
created_at: Optional[str] = None,
|
|
116
|
+
) -> Point:
|
|
89
117
|
"""
|
|
90
118
|
Create Point from given :class:`PointLocation<supervisely.geometry.point_location.PointLocation>` object.
|
|
91
119
|
|
|
@@ -112,8 +140,15 @@ class Point(Geometry):
|
|
|
112
140
|
figure_loc = sly.PointLocation(100, 200)
|
|
113
141
|
figure = sly.Point.from_point_location(figure_loc)
|
|
114
142
|
"""
|
|
115
|
-
return cls(
|
|
116
|
-
|
|
143
|
+
return cls(
|
|
144
|
+
row=pt.row,
|
|
145
|
+
col=pt.col,
|
|
146
|
+
sly_id=sly_id,
|
|
147
|
+
class_id=class_id,
|
|
148
|
+
labeler_login=labeler_login,
|
|
149
|
+
updated_at=updated_at,
|
|
150
|
+
created_at=created_at,
|
|
151
|
+
)
|
|
117
152
|
|
|
118
153
|
@property
|
|
119
154
|
def point_location(self) -> PointLocation:
|
|
@@ -132,9 +167,8 @@ class Point(Geometry):
|
|
|
132
167
|
|
|
133
168
|
@staticmethod
|
|
134
169
|
def geometry_name():
|
|
135
|
-
"""
|
|
136
|
-
""
|
|
137
|
-
return 'point'
|
|
170
|
+
""" """
|
|
171
|
+
return "point"
|
|
138
172
|
|
|
139
173
|
def crop(self, rect: Rectangle) -> List[Point]:
|
|
140
174
|
"""
|
|
@@ -319,7 +353,7 @@ class Point(Geometry):
|
|
|
319
353
|
|
|
320
354
|
def to_json(self) -> Dict:
|
|
321
355
|
"""
|
|
322
|
-
Convert the Point to a json dict. Read more about `Supervisely format <https://docs.
|
|
356
|
+
Convert the Point to a json dict. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
323
357
|
|
|
324
358
|
:return: Json format as a dict
|
|
325
359
|
:rtype: :class:`dict`
|
|
@@ -345,7 +379,7 @@ class Point(Geometry):
|
|
|
345
379
|
@classmethod
|
|
346
380
|
def from_json(cls, data: Dict) -> Point:
|
|
347
381
|
"""
|
|
348
|
-
Convert a json dict to Point. Read more about `Supervisely format <https://docs.
|
|
382
|
+
Convert a json dict to Point. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
349
383
|
|
|
350
384
|
:param data: Point in json format as a dict.
|
|
351
385
|
:type data: dict
|
|
@@ -372,13 +406,18 @@ class Point(Geometry):
|
|
|
372
406
|
created_at = data.get(CREATED_AT, None)
|
|
373
407
|
sly_id = data.get(ID, None)
|
|
374
408
|
class_id = data.get(CLASS_ID, None)
|
|
375
|
-
return cls.from_point_location(
|
|
376
|
-
|
|
377
|
-
|
|
409
|
+
return cls.from_point_location(
|
|
410
|
+
PointLocation.from_json(data),
|
|
411
|
+
sly_id=sly_id,
|
|
412
|
+
class_id=class_id,
|
|
413
|
+
labeler_login=labeler_login,
|
|
414
|
+
updated_at=updated_at,
|
|
415
|
+
created_at=created_at,
|
|
416
|
+
)
|
|
378
417
|
|
|
379
418
|
@classmethod
|
|
380
419
|
def allowed_transforms(cls):
|
|
381
|
-
"""
|
|
382
|
-
"""
|
|
420
|
+
""" """
|
|
383
421
|
from supervisely.geometry.any_geometry import AnyGeometry
|
|
422
|
+
|
|
384
423
|
return [AnyGeometry]
|
|
@@ -73,7 +73,7 @@ class PointLocation(JsonSerializable):
|
|
|
73
73
|
|
|
74
74
|
def to_json(self) -> Dict:
|
|
75
75
|
"""
|
|
76
|
-
Convert the PointLocation to a json dict. Read more about `Supervisely format <https://docs.
|
|
76
|
+
Convert the PointLocation to a json dict. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
77
77
|
|
|
78
78
|
:return: Json format as a dict
|
|
79
79
|
:rtype: :class:`dict`
|
|
@@ -101,7 +101,7 @@ class PointLocation(JsonSerializable):
|
|
|
101
101
|
@classmethod
|
|
102
102
|
def from_json(cls, data: Dict) -> PointLocation:
|
|
103
103
|
"""
|
|
104
|
-
Convert a json dict to PointLocation. Read more about `Supervisely format <https://docs.
|
|
104
|
+
Convert a json dict to PointLocation. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
105
105
|
|
|
106
106
|
:param data: PointLocation in json format as a dict.
|
|
107
107
|
:type data: dict
|
supervisely/geometry/polygon.py
CHANGED
|
@@ -113,7 +113,7 @@ class Polygon(VectorGeometry):
|
|
|
113
113
|
@classmethod
|
|
114
114
|
def from_json(cls, data: Dict) -> Polygon:
|
|
115
115
|
"""
|
|
116
|
-
Convert a json dict to Polygon. Read more about `Supervisely format <https://docs.
|
|
116
|
+
Convert a json dict to Polygon. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
117
117
|
|
|
118
118
|
:param data: Polygon in json format as a dict.
|
|
119
119
|
:type data: dict
|
|
@@ -297,8 +297,8 @@ class Polygon(VectorGeometry):
|
|
|
297
297
|
@classmethod
|
|
298
298
|
def allowed_transforms(cls):
|
|
299
299
|
""" """
|
|
300
|
-
from supervisely.geometry.any_geometry import AnyGeometry
|
|
301
300
|
from supervisely.geometry.alpha_mask import AlphaMask
|
|
301
|
+
from supervisely.geometry.any_geometry import AnyGeometry
|
|
302
302
|
from supervisely.geometry.bitmap import Bitmap
|
|
303
303
|
from supervisely.geometry.rectangle import Rectangle
|
|
304
304
|
|
supervisely/geometry/polyline.py
CHANGED
|
@@ -4,27 +4,31 @@
|
|
|
4
4
|
# docs
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Dict, List, Optional, Tuple, Union
|
|
9
|
+
|
|
7
10
|
import cv2
|
|
8
11
|
import numpy as np
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
+
from shapely.geometry import LineString
|
|
13
|
+
from shapely.geometry import Polygon as ShapelyPolygon
|
|
14
|
+
from shapely.geometry import mapping
|
|
12
15
|
|
|
13
|
-
from
|
|
14
|
-
from supervisely.geometry
|
|
15
|
-
from supervisely.geometry.point_location import row_col_list_to_points
|
|
16
|
-
from supervisely.geometry.vector_geometry import VectorGeometry
|
|
16
|
+
from supervisely import logger
|
|
17
|
+
from supervisely.geometry import validation
|
|
17
18
|
from supervisely.geometry.constants import (
|
|
19
|
+
CLASS_ID,
|
|
20
|
+
CREATED_AT,
|
|
18
21
|
EXTERIOR,
|
|
19
|
-
|
|
22
|
+
ID,
|
|
20
23
|
LABELER_LOGIN,
|
|
24
|
+
POINTS,
|
|
21
25
|
UPDATED_AT,
|
|
22
|
-
CREATED_AT,
|
|
23
|
-
ID,
|
|
24
|
-
CLASS_ID,
|
|
25
26
|
)
|
|
26
|
-
from supervisely.geometry import
|
|
27
|
-
from supervisely import
|
|
27
|
+
from supervisely.geometry.conversions import shapely_figure_to_coords_list
|
|
28
|
+
from supervisely.geometry.point import PointLocation
|
|
29
|
+
from supervisely.geometry.point_location import row_col_list_to_points
|
|
30
|
+
from supervisely.geometry.rectangle import Rectangle
|
|
31
|
+
from supervisely.geometry.vector_geometry import VectorGeometry
|
|
28
32
|
|
|
29
33
|
|
|
30
34
|
class Polyline(VectorGeometry):
|
|
@@ -59,15 +63,12 @@ class Polyline(VectorGeometry):
|
|
|
59
63
|
|
|
60
64
|
@staticmethod
|
|
61
65
|
def geometry_name():
|
|
62
|
-
"""
|
|
63
|
-
"""
|
|
66
|
+
""" """
|
|
64
67
|
return "line"
|
|
65
68
|
|
|
66
69
|
def __init__(
|
|
67
70
|
self,
|
|
68
|
-
exterior: Union[
|
|
69
|
-
List[PointLocation], List[List[int, int]], List[Tuple[int, int]]
|
|
70
|
-
],
|
|
71
|
+
exterior: Union[List[PointLocation], List[List[int, int]], List[Tuple[int, int]]],
|
|
71
72
|
sly_id: Optional[int] = None,
|
|
72
73
|
class_id: Optional[int] = None,
|
|
73
74
|
labeler_login: Optional[int] = None,
|
|
@@ -75,7 +76,9 @@ class Polyline(VectorGeometry):
|
|
|
75
76
|
created_at: Optional[str] = None,
|
|
76
77
|
):
|
|
77
78
|
if len(exterior) < 2:
|
|
78
|
-
raise ValueError(
|
|
79
|
+
raise ValueError(
|
|
80
|
+
f'"{EXTERIOR}" field must contain at least two points to create "Polyline" object.'
|
|
81
|
+
)
|
|
79
82
|
|
|
80
83
|
super().__init__(
|
|
81
84
|
exterior=exterior,
|
|
@@ -90,7 +93,7 @@ class Polyline(VectorGeometry):
|
|
|
90
93
|
@classmethod
|
|
91
94
|
def from_json(cls, data: Dict) -> Polyline:
|
|
92
95
|
"""
|
|
93
|
-
Convert a json dict to Polyline. Read more about `Supervisely format <https://docs.
|
|
96
|
+
Convert a json dict to Polyline. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
94
97
|
|
|
95
98
|
:param data: Polyline in json format as a dict.
|
|
96
99
|
:type data: dict
|
|
@@ -121,9 +124,7 @@ class Polyline(VectorGeometry):
|
|
|
121
124
|
sly_id = data.get(ID, None)
|
|
122
125
|
class_id = data.get(CLASS_ID, None)
|
|
123
126
|
return cls(
|
|
124
|
-
exterior=row_col_list_to_points(
|
|
125
|
-
data[POINTS][EXTERIOR], flip_row_col_order=True
|
|
126
|
-
),
|
|
127
|
+
exterior=row_col_list_to_points(data[POINTS][EXTERIOR], flip_row_col_order=True),
|
|
127
128
|
sly_id=sly_id,
|
|
128
129
|
class_id=class_id,
|
|
129
130
|
labeler_login=labeler_login,
|
|
@@ -158,9 +159,7 @@ class Polyline(VectorGeometry):
|
|
|
158
159
|
clipping_window_shpl = ShapelyPolygon(clipping_window)
|
|
159
160
|
|
|
160
161
|
exterior = self.exterior_np
|
|
161
|
-
intersections_polygon = LineString(exterior).intersection(
|
|
162
|
-
clipping_window_shpl
|
|
163
|
-
)
|
|
162
|
+
intersections_polygon = LineString(exterior).intersection(clipping_window_shpl)
|
|
164
163
|
mapping_shpl = mapping(intersections_polygon)
|
|
165
164
|
except Exception:
|
|
166
165
|
logger.warn("Line cropping exception, shapely.", exc_info=False)
|
|
@@ -182,17 +181,13 @@ class Polyline(VectorGeometry):
|
|
|
182
181
|
return [Polyline(row_col_list_to_points(line)) for line in lines_combined]
|
|
183
182
|
|
|
184
183
|
def _draw_impl(self, bitmap: np.ndarray, color, thickness=1, config=None):
|
|
185
|
-
"""
|
|
186
|
-
"""
|
|
184
|
+
""" """
|
|
187
185
|
self._draw_contour_impl(bitmap, color, thickness, config=config)
|
|
188
186
|
|
|
189
187
|
def _draw_contour_impl(self, bitmap: np.ndarray, color, thickness=1, config=None):
|
|
190
|
-
"""
|
|
191
|
-
"""
|
|
188
|
+
""" """
|
|
192
189
|
exterior = self.exterior_np[:, ::-1]
|
|
193
|
-
cv2.polylines(
|
|
194
|
-
bitmap, pts=[exterior], isClosed=False, color=color, thickness=thickness
|
|
195
|
-
)
|
|
190
|
+
cv2.polylines(bitmap, pts=[exterior], isClosed=False, color=color, thickness=thickness)
|
|
196
191
|
|
|
197
192
|
@property
|
|
198
193
|
def area(self) -> float:
|
|
@@ -227,20 +222,17 @@ class Polyline(VectorGeometry):
|
|
|
227
222
|
# Remember that Polyline class object is immutable, and we need to assign new instance of Polyline to a new variable
|
|
228
223
|
approx_figure = figure.approx_dp(0.75)
|
|
229
224
|
"""
|
|
230
|
-
exterior_np = self._approx_ring_dp(
|
|
231
|
-
self.exterior_np, epsilon, closed=True
|
|
232
|
-
).tolist()
|
|
225
|
+
exterior_np = self._approx_ring_dp(self.exterior_np, epsilon, closed=True).tolist()
|
|
233
226
|
exterior = row_col_list_to_points(exterior_np, do_round=True)
|
|
234
227
|
return Polyline(exterior)
|
|
235
228
|
|
|
236
229
|
@classmethod
|
|
237
230
|
def allowed_transforms(cls):
|
|
238
|
-
"""
|
|
239
|
-
"""
|
|
240
|
-
from supervisely.geometry.any_geometry import AnyGeometry
|
|
241
|
-
from supervisely.geometry.rectangle import Rectangle
|
|
231
|
+
""" """
|
|
242
232
|
from supervisely.geometry.alpha_mask import AlphaMask
|
|
233
|
+
from supervisely.geometry.any_geometry import AnyGeometry
|
|
243
234
|
from supervisely.geometry.bitmap import Bitmap
|
|
244
235
|
from supervisely.geometry.polygon import Polygon
|
|
236
|
+
from supervisely.geometry.rectangle import Rectangle
|
|
245
237
|
|
|
246
238
|
return [AnyGeometry, Rectangle, Bitmap, Polygon, AlphaMask]
|
|
@@ -106,7 +106,7 @@ class Rectangle(Geometry):
|
|
|
106
106
|
|
|
107
107
|
def to_json(self) -> Dict:
|
|
108
108
|
"""
|
|
109
|
-
Convert the Rectangle to a json dict. Read more about `Supervisely format <https://docs.
|
|
109
|
+
Convert the Rectangle to a json dict. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
110
110
|
|
|
111
111
|
:return: Json format as a dict
|
|
112
112
|
:rtype: :class:`dict`
|
|
@@ -138,7 +138,7 @@ class Rectangle(Geometry):
|
|
|
138
138
|
@classmethod
|
|
139
139
|
def from_json(cls, data: Dict) -> Rectangle:
|
|
140
140
|
"""
|
|
141
|
-
Convert a json dict to Rectangle. Read more about `Supervisely format <https://docs.
|
|
141
|
+
Convert a json dict to Rectangle. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
142
142
|
|
|
143
143
|
:param data: Rectangle in json format as a dict.
|
|
144
144
|
:type data: dict
|
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
# docs
|
|
4
4
|
from __future__ import annotations
|
|
5
|
+
|
|
5
6
|
from copy import deepcopy
|
|
7
|
+
from typing import Dict, Iterable, List, Optional, Tuple, Union
|
|
8
|
+
|
|
6
9
|
import cv2
|
|
7
10
|
import numpy as np
|
|
8
|
-
from typing import List, Tuple, Dict, Optional, Union, Iterable
|
|
9
|
-
from supervisely.geometry.image_rotator import ImageRotator
|
|
10
11
|
|
|
11
12
|
from supervisely.geometry.constants import (
|
|
12
13
|
EXTERIOR,
|
|
13
|
-
INTERIOR,
|
|
14
|
-
POINTS,
|
|
15
14
|
GEOMETRY_SHAPE,
|
|
16
15
|
GEOMETRY_TYPE,
|
|
16
|
+
INTERIOR,
|
|
17
|
+
POINTS,
|
|
17
18
|
)
|
|
18
19
|
from supervisely.geometry.geometry import Geometry
|
|
20
|
+
from supervisely.geometry.image_rotator import ImageRotator
|
|
19
21
|
from supervisely.geometry.point_location import PointLocation, points_to_row_col_list
|
|
20
22
|
from supervisely.geometry.rectangle import Rectangle
|
|
21
23
|
|
|
@@ -57,20 +59,18 @@ class VectorGeometry(Geometry):
|
|
|
57
59
|
"""
|
|
58
60
|
|
|
59
61
|
def __init__(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
updated_at: Optional[str] = None,
|
|
73
|
-
created_at: Optional[str] = None,
|
|
62
|
+
self,
|
|
63
|
+
exterior: Union[List[PointLocation], List[List[int, int]], List[Tuple[int, int]]],
|
|
64
|
+
interior: Union[
|
|
65
|
+
List[List[PointLocation]],
|
|
66
|
+
List[List[List[int, int]]],
|
|
67
|
+
List[List[Tuple[int, int]]],
|
|
68
|
+
] = [],
|
|
69
|
+
sly_id: Optional[int] = None,
|
|
70
|
+
class_id: Optional[int] = None,
|
|
71
|
+
labeler_login: Optional[int] = None,
|
|
72
|
+
updated_at: Optional[str] = None,
|
|
73
|
+
created_at: Optional[str] = None,
|
|
74
74
|
):
|
|
75
75
|
result_exterior = []
|
|
76
76
|
if not isinstance(exterior, list):
|
|
@@ -89,9 +89,7 @@ class VectorGeometry(Geometry):
|
|
|
89
89
|
|
|
90
90
|
result_interior = []
|
|
91
91
|
if not isinstance(interior, list):
|
|
92
|
-
raise TypeError(
|
|
93
|
-
'Argument "interior" must be a list of lists with coordinates'
|
|
94
|
-
)
|
|
92
|
+
raise TypeError('Argument "interior" must be a list of lists with coordinates')
|
|
95
93
|
for coords in interior:
|
|
96
94
|
if not isinstance(interior, list):
|
|
97
95
|
raise TypeError('"interior" coords must be a list of coordinates')
|
|
@@ -121,7 +119,7 @@ class VectorGeometry(Geometry):
|
|
|
121
119
|
|
|
122
120
|
def to_json(self) -> Dict:
|
|
123
121
|
"""
|
|
124
|
-
Convert the VectorGeometry to a json dict. Read more about `Supervisely format <https://docs.
|
|
122
|
+
Convert the VectorGeometry to a json dict. Read more about `Supervisely format <https://docs.supervisely.com/data-organization/00_ann_format_navi>`_.
|
|
125
123
|
|
|
126
124
|
:return: Json format as a dict
|
|
127
125
|
:rtype: :class:`dict`
|
|
@@ -150,12 +148,9 @@ class VectorGeometry(Geometry):
|
|
|
150
148
|
"""
|
|
151
149
|
packed_obj = {
|
|
152
150
|
POINTS: {
|
|
153
|
-
EXTERIOR: points_to_row_col_list(
|
|
154
|
-
self._exterior, flip_row_col_order=True
|
|
155
|
-
),
|
|
151
|
+
EXTERIOR: points_to_row_col_list(self._exterior, flip_row_col_order=True),
|
|
156
152
|
INTERIOR: [
|
|
157
|
-
points_to_row_col_list(i, flip_row_col_order=True)
|
|
158
|
-
for i in self._interior
|
|
153
|
+
points_to_row_col_list(i, flip_row_col_order=True) for i in self._interior
|
|
159
154
|
],
|
|
160
155
|
},
|
|
161
156
|
GEOMETRY_SHAPE: self.geometry_name(),
|
|
@@ -232,21 +227,16 @@ class VectorGeometry(Geometry):
|
|
|
232
227
|
# [2468, 875],
|
|
233
228
|
# [2679, 1577]])]
|
|
234
229
|
"""
|
|
235
|
-
return [
|
|
236
|
-
np.array(points_to_row_col_list(i), dtype=np.int64) for i in self._interior
|
|
237
|
-
]
|
|
230
|
+
return [np.array(points_to_row_col_list(i), dtype=np.int64) for i in self._interior]
|
|
238
231
|
|
|
239
232
|
def _transform(self, transform_fn):
|
|
240
|
-
"""
|
|
241
|
-
"""
|
|
233
|
+
""" """
|
|
242
234
|
result = deepcopy(self)
|
|
243
235
|
result._exterior = [transform_fn(p) for p in self._exterior]
|
|
244
236
|
result._interior = [[transform_fn(p) for p in i] for i in self._interior]
|
|
245
237
|
return result
|
|
246
238
|
|
|
247
|
-
def resize(
|
|
248
|
-
self, in_size: Tuple[int, int], out_size: Tuple[int, int]
|
|
249
|
-
) -> VectorGeometry:
|
|
239
|
+
def resize(self, in_size: Tuple[int, int], out_size: Tuple[int, int]) -> VectorGeometry:
|
|
250
240
|
"""
|
|
251
241
|
Resizes current VectorGeometry.
|
|
252
242
|
|
|
@@ -407,8 +397,7 @@ class VectorGeometry(Geometry):
|
|
|
407
397
|
|
|
408
398
|
@staticmethod
|
|
409
399
|
def _approx_ring_dp(ring, epsilon, closed):
|
|
410
|
-
"""
|
|
411
|
-
"""
|
|
400
|
+
""" """
|
|
412
401
|
new_ring = cv2.approxPolyDP(ring.astype(np.int32), epsilon, closed)
|
|
413
402
|
new_ring = np.squeeze(new_ring, 1)
|
|
414
403
|
if len(new_ring) < 3 and closed:
|
|
@@ -416,6 +405,5 @@ class VectorGeometry(Geometry):
|
|
|
416
405
|
return new_ring
|
|
417
406
|
|
|
418
407
|
def approx_dp(self, epsilon):
|
|
419
|
-
"""
|
|
420
|
-
"""
|
|
408
|
+
""" """
|
|
421
409
|
raise NotImplementedError()
|
supervisely/io/env.py
CHANGED
|
@@ -50,7 +50,7 @@ def _parse_from_env(
|
|
|
50
50
|
# env not found
|
|
51
51
|
if raise_not_found is True:
|
|
52
52
|
raise KeyError(
|
|
53
|
-
f"{name} is not defined as environment variable. One of the envs has to be defined: {keys}. Learn more in developer portal: https://developer.
|
|
53
|
+
f"{name} is not defined as environment variable. One of the envs has to be defined: {keys}. Learn more in developer portal: https://developer.supervisely.com/getting-started/environment-variables"
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
return default
|
|
@@ -571,6 +571,7 @@ def supervisely_server_path_prefix() -> str:
|
|
|
571
571
|
raise_not_found=False,
|
|
572
572
|
)
|
|
573
573
|
|
|
574
|
+
|
|
574
575
|
def supervisely_skip_https_user_helper_check() -> bool:
|
|
575
576
|
"""Returns decision to skip `_check_https_redirect` for API from environment variable using following
|
|
576
577
|
- SUPERVISELY_SKIP_HTTPS_USER_HELPER_CHECK"
|
|
@@ -584,4 +585,4 @@ def supervisely_skip_https_user_helper_check() -> bool:
|
|
|
584
585
|
postprocess_fn=flag_from_env,
|
|
585
586
|
default=False,
|
|
586
587
|
raise_not_found=False,
|
|
587
|
-
)
|
|
588
|
+
)
|
|
@@ -279,7 +279,7 @@ def get_job_url(server_address: str, job: NamedTuple) -> str:
|
|
|
279
279
|
|
|
280
280
|
.. code-block:: python
|
|
281
281
|
|
|
282
|
-
address = 'https://app.
|
|
282
|
+
address = 'https://app.supervisely.com'
|
|
283
283
|
os.environ['SERVER_ADDRESS'] = address
|
|
284
284
|
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
|
|
285
285
|
api = sly.Api.from_env()
|
|
@@ -288,7 +288,7 @@ def get_job_url(server_address: str, job: NamedTuple) -> str:
|
|
|
288
288
|
from supervisely.labeling_jobs.utils import get_job_url
|
|
289
289
|
job_url = get_job_url(address, job_info)
|
|
290
290
|
print(job_url)
|
|
291
|
-
# Output: https://app.
|
|
291
|
+
# Output: https://app.supervisely.com/app/images/4/8/58/54?jobId=2
|
|
292
292
|
"""
|
|
293
293
|
result = urllib.parse.urljoin(
|
|
294
294
|
server_address,
|
|
@@ -322,15 +322,15 @@ def jobs_stats(server_address: str, jobs: List[NamedTuple], stats: List) -> Data
|
|
|
322
322
|
|
|
323
323
|
job_info1 = api.labeling_job.get_info_by_id(2)
|
|
324
324
|
job_info2 = api.labeling_job.get_info_by_id(3)
|
|
325
|
-
address = https://app.
|
|
325
|
+
address = https://app.supervisely.com
|
|
326
326
|
|
|
327
327
|
from supervisely.labeling_jobs.utils import jobs_stats
|
|
328
328
|
result = jobs_stats(address, [job_info1, job_info2], [1, 2])
|
|
329
329
|
print(result)
|
|
330
330
|
# Output:
|
|
331
331
|
# ID NAME STATUS TOTAL LABELED REVIEWED ACCEPTED REJECTED CREATED_AT
|
|
332
|
-
# 0 2 <a href="https://app.
|
|
333
|
-
# 1 3 <a href="https://app.
|
|
332
|
+
# 0 2 <a href="https://app.supervisely.com/app/images/... completed 3 3 3 2 1 08/04/2020 15:10
|
|
333
|
+
# 1 3 <a href="https://app.supervisely.com/app/images/... completed 2 2 2 2 0 08/04/2020 15:10
|
|
334
334
|
"""
|
|
335
335
|
import pandas as pd
|
|
336
336
|
|
|
@@ -173,9 +173,9 @@ class PredictionSession:
|
|
|
173
173
|
ext = get_file_ext(input[0])
|
|
174
174
|
if ext == "":
|
|
175
175
|
raise ValueError("File has no extension.")
|
|
176
|
-
if ext in SUPPORTED_IMG_EXTS:
|
|
176
|
+
if ext.lower() in SUPPORTED_IMG_EXTS:
|
|
177
177
|
self._iterator = self._predict_images(input, **kwargs)
|
|
178
|
-
elif ext in ALLOWED_VIDEO_EXTENSIONS:
|
|
178
|
+
elif ext.lower() in ALLOWED_VIDEO_EXTENSIONS:
|
|
179
179
|
kwargs = get_valid_kwargs(kwargs, self._predict_videos, exclude=["videos"])
|
|
180
180
|
self._iterator = self._predict_videos(input, **kwargs)
|
|
181
181
|
else:
|
|
@@ -225,7 +225,7 @@ def get_labeling_tool_url(dataset_id: int, pointcloud_id: int):
|
|
|
225
225
|
api = sly.Api.from_env()
|
|
226
226
|
|
|
227
227
|
# Pass values into the API constructor (optional, not recommended)
|
|
228
|
-
# api = sly.Api(server_address="https://app.
|
|
228
|
+
# api = sly.Api(server_address="https://app.supervisely.com", token="4r47N...xaTatb")
|
|
229
229
|
|
|
230
230
|
pointcloud_id = 19373403
|
|
231
231
|
pcd_info = api.pointcloud.get_info_by_id(pointcloud_id)
|
|
@@ -268,7 +268,7 @@ def get_labeling_tool_link(url, name="open in labeling tool"):
|
|
|
268
268
|
api = sly.Api.from_env()
|
|
269
269
|
|
|
270
270
|
# Pass values into the API constructor (optional, not recommended)
|
|
271
|
-
# api = sly.Api(server_address="https://app.
|
|
271
|
+
# api = sly.Api(server_address="https://app.supervisely.com", token="4r47N...xaTatb")
|
|
272
272
|
|
|
273
273
|
pointcloud_id = 19373403
|
|
274
274
|
pcd_info = api.pointcloud.get_info_by_id(pointcloud_id)
|