supervisely 6.73.276__py3-none-any.whl → 6.73.278__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.
Potentially problematic release.
This version of supervisely might be problematic. Click here for more details.
- supervisely/__init__.py +2 -0
- supervisely/annotation/annotation.py +138 -1
- supervisely/convert/__init__.py +12 -55
- supervisely/convert/base_converter.py +13 -1
- supervisely/convert/image/__init__.py +22 -0
- supervisely/convert/image/coco/coco_helper.py +494 -2
- supervisely/convert/image/pascal_voc/pascal_voc_helper.py +417 -11
- supervisely/convert/image/yolo/yolo_helper.py +339 -4
- supervisely/convert/pointcloud/__init__.py +8 -0
- supervisely/convert/pointcloud/kitti_3d/__init__.py +0 -0
- supervisely/convert/pointcloud/kitti_3d/kitti_3d_converter.py +139 -0
- supervisely/convert/pointcloud/kitti_3d/kitti_3d_helper.py +110 -0
- supervisely/convert/pointcloud_episodes/__init__.py +9 -0
- supervisely/convert/video/__init__.py +3 -0
- supervisely/convert/volume/__init__.py +3 -0
- supervisely/nn/training/gui/training_artifacts.py +1 -1
- supervisely/nn/training/train_app.py +3 -2
- supervisely/project/project.py +311 -2
- {supervisely-6.73.276.dist-info → supervisely-6.73.278.dist-info}/METADATA +1 -1
- {supervisely-6.73.276.dist-info → supervisely-6.73.278.dist-info}/RECORD +24 -21
- {supervisely-6.73.276.dist-info → supervisely-6.73.278.dist-info}/LICENSE +0 -0
- {supervisely-6.73.276.dist-info → supervisely-6.73.278.dist-info}/WHEEL +0 -0
- {supervisely-6.73.276.dist-info → supervisely-6.73.278.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.276.dist-info → supervisely-6.73.278.dist-info}/top_level.txt +0 -0
supervisely/__init__.py
CHANGED
|
@@ -9,7 +9,7 @@ import json
|
|
|
9
9
|
import operator
|
|
10
10
|
from collections import defaultdict
|
|
11
11
|
from copy import deepcopy
|
|
12
|
-
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union
|
|
12
|
+
from typing import TYPE_CHECKING, Callable, Dict, List, Literal, Optional, Tuple, Union
|
|
13
13
|
|
|
14
14
|
import numpy as np
|
|
15
15
|
from PIL import Image
|
|
@@ -3002,3 +3002,140 @@ class Annotation:
|
|
|
3002
3002
|
# new_labels = [label._to_subpixel_coordinate_system() for label in new_ann.labels]
|
|
3003
3003
|
# new_ann._labels = new_labels
|
|
3004
3004
|
# return new_ann
|
|
3005
|
+
|
|
3006
|
+
def to_coco(
|
|
3007
|
+
self,
|
|
3008
|
+
coco_image_id: int,
|
|
3009
|
+
class_mapping: Dict[str, int],
|
|
3010
|
+
coco_ann: Optional[Union[Dict, List]] = None,
|
|
3011
|
+
last_label_id: Optional[int] = None,
|
|
3012
|
+
coco_captions: Optional[Union[Dict, List]] = None,
|
|
3013
|
+
last_caption_id: Optional[int] = None,
|
|
3014
|
+
) -> Tuple[List, List]:
|
|
3015
|
+
"""
|
|
3016
|
+
Convert Supervisely annotation to COCO format annotation ("annotations" field).
|
|
3017
|
+
|
|
3018
|
+
:param coco_image_id: Image id in COCO format.
|
|
3019
|
+
:type coco_image_id: int
|
|
3020
|
+
:param class_mapping: Dictionary that maps class names to class ids.
|
|
3021
|
+
:type class_mapping: Dict[str, int]
|
|
3022
|
+
:param coco_ann: COCO annotation in dictionary or list format to append new annotations.
|
|
3023
|
+
:type coco_ann: Union[Dict, List], optional
|
|
3024
|
+
:param last_label_id: Last label id in COCO format to continue counting.
|
|
3025
|
+
:type last_label_id: int, optional
|
|
3026
|
+
:param coco_captions: COCO captions in dictionary or list format to append new captions.
|
|
3027
|
+
:type coco_captions: Union[Dict, List], optional
|
|
3028
|
+
:return: Tuple with list of COCO objects and list of COCO captions.
|
|
3029
|
+
:rtype: :class:`tuple`
|
|
3030
|
+
|
|
3031
|
+
|
|
3032
|
+
:Usage example:
|
|
3033
|
+
|
|
3034
|
+
.. code-block:: python
|
|
3035
|
+
|
|
3036
|
+
import supervisely as sly
|
|
3037
|
+
|
|
3038
|
+
|
|
3039
|
+
coco_instances = dict(
|
|
3040
|
+
info=dict(
|
|
3041
|
+
description="COCO dataset converted from Supervisely",
|
|
3042
|
+
url="None",
|
|
3043
|
+
version=str(1.0),
|
|
3044
|
+
year=2025,
|
|
3045
|
+
contributor="Supervisely",
|
|
3046
|
+
date_created="2025-01-01 00:00:00",
|
|
3047
|
+
),
|
|
3048
|
+
licenses=[dict(url="None", id=0, name="None")],
|
|
3049
|
+
images=[],
|
|
3050
|
+
annotations=[],
|
|
3051
|
+
categories=get_categories_from_meta(meta), # [{"supercategory": "lemon", "id": 0, "name": "lemon"}, ...]
|
|
3052
|
+
)
|
|
3053
|
+
|
|
3054
|
+
ann = sly.Annotation.from_json(ann_json, meta)
|
|
3055
|
+
image_id = 11
|
|
3056
|
+
label_id = 222
|
|
3057
|
+
class_mapping = {obj_cls.name: idx for idx, obj_cls in enumerate(meta.obj_classes)}
|
|
3058
|
+
|
|
3059
|
+
curr_coco_ann, _ = ann.to_coco(image_id, class_mapping, coco_instances, label_id)
|
|
3060
|
+
# or
|
|
3061
|
+
# curr_coco_ann, _ = ann.to_coco(image_id, class_mapping, label_id=label_id)
|
|
3062
|
+
# coco_instances["annotations"].extend(curr_coco_ann)
|
|
3063
|
+
|
|
3064
|
+
label_id += len(curr_coco_ann)
|
|
3065
|
+
image_id += 1
|
|
3066
|
+
"""
|
|
3067
|
+
|
|
3068
|
+
from supervisely.convert.image.coco.coco_helper import sly_ann_to_coco
|
|
3069
|
+
|
|
3070
|
+
return sly_ann_to_coco(
|
|
3071
|
+
ann=self,
|
|
3072
|
+
coco_image_id=coco_image_id,
|
|
3073
|
+
class_mapping=class_mapping,
|
|
3074
|
+
coco_ann=coco_ann,
|
|
3075
|
+
last_label_id=last_label_id,
|
|
3076
|
+
coco_captions=coco_captions,
|
|
3077
|
+
last_caption_id=last_caption_id,
|
|
3078
|
+
)
|
|
3079
|
+
|
|
3080
|
+
def to_yolo(
|
|
3081
|
+
self,
|
|
3082
|
+
class_names: List[str],
|
|
3083
|
+
task_type: Literal["detection", "segmentation", "pose"] = "detection",
|
|
3084
|
+
) -> List[str]:
|
|
3085
|
+
"""
|
|
3086
|
+
Convert Supervisely annotation to YOLO annotation format.
|
|
3087
|
+
Returns a list of strings, each string represents one object.
|
|
3088
|
+
|
|
3089
|
+
:param class_names: List of class names.
|
|
3090
|
+
:type class_names: List[str]
|
|
3091
|
+
:param task_type: Task type, one of "detection", "segmentation", "pose".
|
|
3092
|
+
:type task_type: str
|
|
3093
|
+
:return: List of objects in YOLO format.
|
|
3094
|
+
:rtype: :class:`list`
|
|
3095
|
+
|
|
3096
|
+
:Usage example:
|
|
3097
|
+
|
|
3098
|
+
.. code-block:: python
|
|
3099
|
+
|
|
3100
|
+
import supervisely as sly
|
|
3101
|
+
|
|
3102
|
+
ann = sly.Annotation.from_json(ann_json, meta)
|
|
3103
|
+
class_names = [obj_cls.name for obj_cls in meta.obj_classes]
|
|
3104
|
+
|
|
3105
|
+
yolo_lines = ann.to_yolo(class_names, task_type="segmentation")
|
|
3106
|
+
"""
|
|
3107
|
+
|
|
3108
|
+
from supervisely.convert.image.yolo.yolo_helper import sly_ann_to_yolo
|
|
3109
|
+
|
|
3110
|
+
return sly_ann_to_yolo(ann=self, class_names=class_names, task_type=task_type)
|
|
3111
|
+
|
|
3112
|
+
def to_pascal_voc(
|
|
3113
|
+
self,
|
|
3114
|
+
image_name: str,
|
|
3115
|
+
) -> Tuple[List, List]:
|
|
3116
|
+
"""
|
|
3117
|
+
Convert Supervisely annotation to Pascal VOC format annotation ("annotations" field).
|
|
3118
|
+
|
|
3119
|
+
:param ann: Supervisely annotation.
|
|
3120
|
+
:type ann: :class:`Annotation<supervisely.annotation.annotation.Annotation>`
|
|
3121
|
+
:param image_name: Image name.
|
|
3122
|
+
:type image_name: :class:`str`
|
|
3123
|
+
:return: Tuple with xml tree and instance and class masks in PIL.Image format.
|
|
3124
|
+
:rtype: :class:`Tuple`
|
|
3125
|
+
|
|
3126
|
+
:Usage example:
|
|
3127
|
+
|
|
3128
|
+
.. code-block:: python
|
|
3129
|
+
|
|
3130
|
+
import supervisely as sly
|
|
3131
|
+
from supervisely.convert.image.pascal_voc.pascal_voc_helper import sly_ann_to_pascal_voc
|
|
3132
|
+
|
|
3133
|
+
ann = sly.Annotation.from_json(ann_json, meta)
|
|
3134
|
+
xml_tree, instance_mask, class_mask = sly_ann_to_pascal_voc(ann, image_name)
|
|
3135
|
+
"""
|
|
3136
|
+
|
|
3137
|
+
from supervisely.convert.image.pascal_voc.pascal_voc_helper import (
|
|
3138
|
+
sly_ann_to_pascal_voc,
|
|
3139
|
+
)
|
|
3140
|
+
|
|
3141
|
+
return sly_ann_to_pascal_voc(self, image_name)
|
supervisely/convert/__init__.py
CHANGED
|
@@ -1,59 +1,16 @@
|
|
|
1
1
|
# isort: skip_file
|
|
2
|
-
from supervisely.convert.base_converter import (
|
|
3
|
-
AvailableImageConverters,
|
|
4
|
-
AvailablePointcloudConverters,
|
|
5
|
-
AvailableVideoConverters,
|
|
6
|
-
AvailableVolumeConverters,
|
|
7
|
-
BaseConverter,
|
|
8
|
-
)
|
|
9
|
-
from supervisely.convert.converter import ImportManager
|
|
10
2
|
|
|
11
|
-
#
|
|
12
|
-
from supervisely.convert.image.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
from supervisely.convert.image.coco.coco_converter import COCOConverter
|
|
16
|
-
from supervisely.convert.image.coco.coco_anntotation_converter import FastCOCOConverter
|
|
17
|
-
from supervisely.convert.image.csv.csv_converter import CSVConverter
|
|
18
|
-
from supervisely.convert.image.multispectral.multispectral_converter import (
|
|
19
|
-
MultiSpectralImageConverter,
|
|
20
|
-
)
|
|
21
|
-
from supervisely.convert.image.medical2d.medical2d_converter import Medical2DImageConverter
|
|
22
|
-
from supervisely.convert.image.masks.images_with_masks_converter import ImagesWithMasksConverter
|
|
3
|
+
# Project
|
|
4
|
+
from supervisely.convert.image.coco.coco_helper import sly_project_to_coco as project_to_coco
|
|
5
|
+
from supervisely.convert.image.yolo.yolo_helper import sly_project_to_yolo as project_to_yolo
|
|
6
|
+
from supervisely.convert.image.pascal_voc.pascal_voc_helper import sly_project_to_pascal_voc as project_to_pascal_voc
|
|
23
7
|
|
|
24
|
-
|
|
25
|
-
from supervisely.convert.image.
|
|
26
|
-
from supervisely.convert.image.
|
|
27
|
-
from supervisely.convert.image.
|
|
28
|
-
from supervisely.convert.image.yolo.yolo_converter import YOLOConverter
|
|
29
|
-
from supervisely.convert.image.multi_view.multi_view import MultiViewImageConverter
|
|
30
|
-
from supervisely.convert.image.label_me.label_me_converter import LabelmeConverter
|
|
31
|
-
from supervisely.convert.image.label_studio.label_studio_converter import LabelStudioConverter
|
|
32
|
-
from supervisely.convert.image.high_color.high_color_depth import HighColorDepthImageConverter
|
|
8
|
+
# Dataset
|
|
9
|
+
from supervisely.convert.image.coco.coco_helper import sly_ds_to_coco as dataset_to_coco
|
|
10
|
+
from supervisely.convert.image.yolo.yolo_helper import sly_ds_to_yolo as dataset_to_yolo
|
|
11
|
+
from supervisely.convert.image.pascal_voc.pascal_voc_helper import sly_ds_to_pascal_voc as dataset_to_pascal_voc
|
|
33
12
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
from supervisely.convert.
|
|
37
|
-
from supervisely.convert.
|
|
38
|
-
from supervisely.convert.pointcloud.ply.ply_converter import PlyConverter
|
|
39
|
-
from supervisely.convert.pointcloud.bag.bag_converter import BagConverter
|
|
40
|
-
from supervisely.convert.pointcloud.lyft.lyft_converter import LyftConverter
|
|
41
|
-
from supervisely.convert.pointcloud.nuscenes_conv.nuscenes_converter import NuscenesConverter
|
|
42
|
-
|
|
43
|
-
# Pointcloud Episodes
|
|
44
|
-
from supervisely.convert.pointcloud_episodes.sly.sly_pointcloud_episodes_converter import (
|
|
45
|
-
SLYPointcloudEpisodesConverter,
|
|
46
|
-
)
|
|
47
|
-
from supervisely.convert.pointcloud_episodes.bag.bag_converter import BagEpisodesConverter
|
|
48
|
-
from supervisely.convert.pointcloud_episodes.lyft.lyft_converter import LyftEpisodesConverter
|
|
49
|
-
from supervisely.convert.pointcloud_episodes.nuscenes_conv.nuscenes_converter import (
|
|
50
|
-
NuscenesEpisodesConverter,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
# Video
|
|
54
|
-
from supervisely.convert.video.mot.mot_converter import MOTConverter
|
|
55
|
-
from supervisely.convert.video.sly.sly_video_converter import SLYVideoConverter
|
|
56
|
-
|
|
57
|
-
# Volume
|
|
58
|
-
from supervisely.convert.volume.sly.sly_volume_converter import SLYVolumeConverter
|
|
59
|
-
from supervisely.convert.volume.dicom.dicom_converter import DICOMConverter
|
|
13
|
+
# Image Annotations
|
|
14
|
+
from supervisely.convert.image.coco.coco_helper import sly_ann_to_coco as annotation_to_coco
|
|
15
|
+
from supervisely.convert.image.yolo.yolo_helper import sly_ann_to_yolo as annotation_to_yolo
|
|
16
|
+
from supervisely.convert.image.pascal_voc.pascal_voc_helper import sly_ann_to_pascal_voc as annotation_to_pascal_voc
|
|
@@ -19,6 +19,8 @@ from supervisely.io.fs import (
|
|
|
19
19
|
silent_remove,
|
|
20
20
|
unpack_archive,
|
|
21
21
|
)
|
|
22
|
+
from supervisely.annotation.obj_class import ObjClass
|
|
23
|
+
from supervisely.geometry.graph import GraphNodes
|
|
22
24
|
from supervisely.project.project_meta import ProjectMeta
|
|
23
25
|
from supervisely.project.project_settings import LabelingInterface
|
|
24
26
|
from supervisely.sly_logger import logger
|
|
@@ -56,6 +58,7 @@ class AvailablePointcloudConverters:
|
|
|
56
58
|
BAG = "rosbag"
|
|
57
59
|
LYFT = "lyft"
|
|
58
60
|
NUSCENES = "nuscenes"
|
|
61
|
+
KITTI3D = "kitti3d"
|
|
59
62
|
|
|
60
63
|
|
|
61
64
|
class AvailablePointcloudEpisodesConverters:
|
|
@@ -343,8 +346,17 @@ class BaseConverter:
|
|
|
343
346
|
i = 1
|
|
344
347
|
new_name = new_cls.name
|
|
345
348
|
matched = False
|
|
349
|
+
def _is_matched(old_cls: ObjClass, new_cls: ObjClass) -> bool:
|
|
350
|
+
if old_cls.geometry_type == new_cls.geometry_type:
|
|
351
|
+
if old_cls.geometry_type == GraphNodes:
|
|
352
|
+
old_nodes = old_cls.geometry_config["nodes"]
|
|
353
|
+
new_nodes = new_cls.geometry_config["nodes"]
|
|
354
|
+
return old_nodes.keys() == new_nodes.keys()
|
|
355
|
+
return True
|
|
356
|
+
return False
|
|
357
|
+
|
|
346
358
|
while meta1.obj_classes.get(new_name) is not None:
|
|
347
|
-
if meta1.
|
|
359
|
+
if _is_matched(meta1.get_obj_class(new_name), new_cls):
|
|
348
360
|
matched = True
|
|
349
361
|
break
|
|
350
362
|
new_name = f"{new_cls.name}_{i}"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Image
|
|
2
|
+
from supervisely.convert.image.cityscapes.cityscapes_converter import (
|
|
3
|
+
CityscapesConverter,
|
|
4
|
+
)
|
|
5
|
+
from supervisely.convert.image.coco.coco_converter import COCOConverter
|
|
6
|
+
from supervisely.convert.image.coco.coco_anntotation_converter import FastCOCOConverter
|
|
7
|
+
from supervisely.convert.image.csv.csv_converter import CSVConverter
|
|
8
|
+
from supervisely.convert.image.multispectral.multispectral_converter import (
|
|
9
|
+
MultiSpectralImageConverter,
|
|
10
|
+
)
|
|
11
|
+
from supervisely.convert.image.medical2d.medical2d_converter import Medical2DImageConverter
|
|
12
|
+
from supervisely.convert.image.masks.images_with_masks_converter import ImagesWithMasksConverter
|
|
13
|
+
|
|
14
|
+
from supervisely.convert.image.pascal_voc.pascal_voc_converter import PascalVOCConverter
|
|
15
|
+
from supervisely.convert.image.pdf.pdf_converter import PDFConverter
|
|
16
|
+
from supervisely.convert.image.sly.sly_image_converter import SLYImageConverter
|
|
17
|
+
from supervisely.convert.image.sly.fast_sly_image_converter import FastSlyImageConverter
|
|
18
|
+
from supervisely.convert.image.yolo.yolo_converter import YOLOConverter
|
|
19
|
+
from supervisely.convert.image.multi_view.multi_view import MultiViewImageConverter
|
|
20
|
+
from supervisely.convert.image.label_me.label_me_converter import LabelmeConverter
|
|
21
|
+
from supervisely.convert.image.label_studio.label_studio_converter import LabelStudioConverter
|
|
22
|
+
from supervisely.convert.image.high_color.high_color_depth import HighColorDepthImageConverter
|