supervisely 6.73.400__py3-none-any.whl → 6.73.402__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/convert/image/sly/sly_image_helper.py +8 -8
- supervisely/convert/video/sly/sly_video_helper.py +31 -11
- supervisely/nn/inference/cache.py +8 -7
- {supervisely-6.73.400.dist-info → supervisely-6.73.402.dist-info}/METADATA +1 -1
- {supervisely-6.73.400.dist-info → supervisely-6.73.402.dist-info}/RECORD +9 -9
- {supervisely-6.73.400.dist-info → supervisely-6.73.402.dist-info}/LICENSE +0 -0
- {supervisely-6.73.400.dist-info → supervisely-6.73.402.dist-info}/WHEEL +0 -0
- {supervisely-6.73.400.dist-info → supervisely-6.73.402.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.400.dist-info → supervisely-6.73.402.dist-info}/top_level.txt +0 -0
|
@@ -33,7 +33,7 @@ def get_meta_from_annotation(ann_json: dict, meta: ProjectMeta) -> ProjectMeta:
|
|
|
33
33
|
ann_json = ann_json.get("annotation", {})
|
|
34
34
|
|
|
35
35
|
if not all(key in ann_json for key in SLY_IMAGE_ANN_KEYS):
|
|
36
|
-
logger.
|
|
36
|
+
logger.warning(
|
|
37
37
|
f"Some keys are missing in the annotation file. "
|
|
38
38
|
"Check the annotation format documentation at: "
|
|
39
39
|
"https://docs.supervisely.com/customization-and-integration/00_ann_format_navi/05_supervisely_format_images"
|
|
@@ -44,7 +44,7 @@ def get_meta_from_annotation(ann_json: dict, meta: ProjectMeta) -> ProjectMeta:
|
|
|
44
44
|
for object in ann_objects:
|
|
45
45
|
obj_tags = object.get(LabelJsonFields.TAGS, None)
|
|
46
46
|
if obj_tags is None:
|
|
47
|
-
logger.
|
|
47
|
+
logger.warning(
|
|
48
48
|
f"Key '{LabelJsonFields.TAGS}' for object tags is missing in the annotation file. Tags will not be added to the meta."
|
|
49
49
|
)
|
|
50
50
|
obj_tags = []
|
|
@@ -52,7 +52,7 @@ def get_meta_from_annotation(ann_json: dict, meta: ProjectMeta) -> ProjectMeta:
|
|
|
52
52
|
meta = create_classes_from_annotation(object, meta)
|
|
53
53
|
img_tags = ann_json.get(AnnotationJsonFields.IMG_TAGS, None)
|
|
54
54
|
if img_tags is None:
|
|
55
|
-
logger.
|
|
55
|
+
logger.warning(
|
|
56
56
|
f"Key '{AnnotationJsonFields.IMG_TAGS}' for image tags is missing in the annotation file. Tags will not be added to the meta."
|
|
57
57
|
)
|
|
58
58
|
img_tags = []
|
|
@@ -63,14 +63,14 @@ def get_meta_from_annotation(ann_json: dict, meta: ProjectMeta) -> ProjectMeta:
|
|
|
63
63
|
def create_tags_from_annotation(tags: List[dict], meta: ProjectMeta) -> ProjectMeta:
|
|
64
64
|
for tag in tags:
|
|
65
65
|
if not all(key in tag for key in SLY_TAG_KEYS):
|
|
66
|
-
logger.
|
|
66
|
+
logger.warning(
|
|
67
67
|
f"Tag in annotation file is not in Supervisely format. "
|
|
68
68
|
"Read more about the Supervisely JSON format of tags in the documentation at: "
|
|
69
69
|
"https://docs.supervisely.com/customization-and-integration/00_ann_format_navi/03_supervisely_format_tags"
|
|
70
70
|
)
|
|
71
71
|
continue
|
|
72
72
|
tag_name = tag[TagJsonFields.TAG_NAME]
|
|
73
|
-
tag_value = tag
|
|
73
|
+
tag_value = tag.get(TagJsonFields.VALUE)
|
|
74
74
|
if tag_value is None:
|
|
75
75
|
tag_meta = TagMeta(tag_name, TagValueType.NONE)
|
|
76
76
|
elif isinstance(tag_value, int) or isinstance(tag_value, float):
|
|
@@ -87,7 +87,7 @@ def create_tags_from_annotation(tags: List[dict], meta: ProjectMeta) -> ProjectM
|
|
|
87
87
|
|
|
88
88
|
def create_classes_from_annotation(object: dict, meta: ProjectMeta) -> ProjectMeta:
|
|
89
89
|
if not all(key in object for key in SLY_OBJECT_KEYS):
|
|
90
|
-
logger.
|
|
90
|
+
logger.warning(
|
|
91
91
|
f"Object in annotation file is not in Supervisely format: {object}. "
|
|
92
92
|
"Read more about the Supervisely JSON format of objects in the documentation at: "
|
|
93
93
|
"https://docs.supervisely.com/customization-and-integration/00_ann_format_navi/04_supervisely_format_objects"
|
|
@@ -100,7 +100,7 @@ def create_classes_from_annotation(object: dict, meta: ProjectMeta) -> ProjectMe
|
|
|
100
100
|
try:
|
|
101
101
|
geometry_type = GET_GEOMETRY_FROM_STR(geometry_type_str)
|
|
102
102
|
except KeyError:
|
|
103
|
-
logger.
|
|
103
|
+
logger.warning(f"Unknown geometry type {geometry_type_str} for class {class_name}")
|
|
104
104
|
return meta
|
|
105
105
|
|
|
106
106
|
obj_class = None
|
|
@@ -117,7 +117,7 @@ def create_classes_from_annotation(object: dict, meta: ProjectMeta) -> ProjectMe
|
|
|
117
117
|
existing_class = meta.get_obj_class(class_name)
|
|
118
118
|
|
|
119
119
|
if obj_class is None:
|
|
120
|
-
logger.
|
|
120
|
+
logger.warning(
|
|
121
121
|
f"Failed to create object class for {class_name} with geometry type {geometry_type_str}"
|
|
122
122
|
)
|
|
123
123
|
return meta
|
|
@@ -14,17 +14,34 @@ from supervisely import (
|
|
|
14
14
|
TagValueType,
|
|
15
15
|
logger,
|
|
16
16
|
)
|
|
17
|
-
from supervisely.geometry.graph import KeypointsTemplate
|
|
18
|
-
from supervisely.io.json import load_json_file
|
|
19
17
|
from supervisely.annotation.label import LabelJsonFields
|
|
20
18
|
from supervisely.annotation.tag import TagJsonFields
|
|
21
|
-
from supervisely.
|
|
19
|
+
from supervisely.geometry.graph import KeypointsTemplate
|
|
20
|
+
from supervisely.io.json import load_json_file
|
|
21
|
+
from supervisely.video_annotation.constants import (
|
|
22
|
+
FIGURES,
|
|
23
|
+
FRAMES,
|
|
24
|
+
FRAMES_COUNT,
|
|
25
|
+
IMG_SIZE,
|
|
26
|
+
INDEX,
|
|
27
|
+
KEY,
|
|
28
|
+
OBJECT_KEY,
|
|
29
|
+
OBJECTS,
|
|
30
|
+
TAGS,
|
|
31
|
+
)
|
|
22
32
|
|
|
23
33
|
SLY_ANN_KEYS = [IMG_SIZE, FRAMES_COUNT, FRAMES, OBJECTS, TAGS]
|
|
24
34
|
SLY_VIDEO_OBJECT_KEYS = [LabelJsonFields.OBJ_CLASS_NAME, LabelJsonFields.TAGS, KEY]
|
|
25
|
-
SLY_TAG_KEYS = [
|
|
35
|
+
SLY_TAG_KEYS = [
|
|
36
|
+
TagJsonFields.TAG_NAME,
|
|
37
|
+
# TagJsonFields.VALUE
|
|
38
|
+
]
|
|
26
39
|
SLY_FRAME_KEYS = [FIGURES, INDEX]
|
|
27
|
-
SLY_FIGURE_KEYS = [
|
|
40
|
+
SLY_FIGURE_KEYS = [
|
|
41
|
+
KEY,
|
|
42
|
+
OBJECT_KEY,
|
|
43
|
+
"geometryType",
|
|
44
|
+
] # , LabelJsonFields.GEOMETRY_TYPE] TODO: add geometry type
|
|
28
45
|
|
|
29
46
|
|
|
30
47
|
def get_meta_from_annotation(ann_path: str, meta: ProjectMeta) -> ProjectMeta:
|
|
@@ -32,7 +49,7 @@ def get_meta_from_annotation(ann_path: str, meta: ProjectMeta) -> ProjectMeta:
|
|
|
32
49
|
if "annotation" in ann_json:
|
|
33
50
|
ann_json = ann_json["annotation"]
|
|
34
51
|
if not all(key in ann_json for key in SLY_ANN_KEYS):
|
|
35
|
-
logger.
|
|
52
|
+
logger.warning(
|
|
36
53
|
f"VideoAnnotation file {ann_path} is not in Supervisely format. "
|
|
37
54
|
"Check the annotation format documentation at: "
|
|
38
55
|
"https://docs.supervisely.com/customization-and-integration/00_ann_format_navi/06_supervisely_format_videos"
|
|
@@ -42,7 +59,7 @@ def get_meta_from_annotation(ann_path: str, meta: ProjectMeta) -> ProjectMeta:
|
|
|
42
59
|
object_key_to_name = {}
|
|
43
60
|
for object in ann_json[OBJECTS]:
|
|
44
61
|
if not all(key in object for key in SLY_VIDEO_OBJECT_KEYS):
|
|
45
|
-
logger.
|
|
62
|
+
logger.warning(
|
|
46
63
|
f"Object in annotation file is not in Supervisely format: {object}. "
|
|
47
64
|
"Read more about the Supervisely JSON format of objects in the documentation at: "
|
|
48
65
|
"https://docs.supervisely.com/customization-and-integration/00_ann_format_navi/06_supervisely_format_videos"
|
|
@@ -52,7 +69,7 @@ def get_meta_from_annotation(ann_path: str, meta: ProjectMeta) -> ProjectMeta:
|
|
|
52
69
|
object_key_to_name[object[KEY]] = object[LabelJsonFields.OBJ_CLASS_NAME]
|
|
53
70
|
for frame in ann_json[FRAMES]:
|
|
54
71
|
if not all(key in frame for key in SLY_FRAME_KEYS):
|
|
55
|
-
logger.
|
|
72
|
+
logger.warning(
|
|
56
73
|
f"Frame in annotation file is not in Supervisely format: {frame}."
|
|
57
74
|
"Read more about the Supervisely JSON format of frames in the documentation at: "
|
|
58
75
|
"https://docs.supervisely.com/customization-and-integration/00_ann_format_navi/06_supervisely_format_videos"
|
|
@@ -86,7 +103,7 @@ def create_classes_from_annotation(
|
|
|
86
103
|
) -> ProjectMeta:
|
|
87
104
|
for fig in frame[FIGURES]:
|
|
88
105
|
if not all(key in fig for key in SLY_FIGURE_KEYS):
|
|
89
|
-
logger.
|
|
106
|
+
logger.warning(
|
|
90
107
|
f"Figure in annotation file is not in Supervisely format: {fig}. "
|
|
91
108
|
"Read more about the Supervisely JSON format of figures in the documentation at: "
|
|
92
109
|
"https://docs.supervisely.com/customization-and-integration/00_ann_format_navi/06_supervisely_format_videos"
|
|
@@ -119,11 +136,13 @@ def create_classes_from_annotation(
|
|
|
119
136
|
if "loc" not in node or len(node["loc"]) != 2:
|
|
120
137
|
continue
|
|
121
138
|
template.add_point(label=uuid, row=node["loc"][0], col=node["loc"][1])
|
|
122
|
-
obj_class = ObjClass(
|
|
139
|
+
obj_class = ObjClass(
|
|
140
|
+
name=class_name, geometry_type=GraphNodes, geometry_config=template
|
|
141
|
+
)
|
|
123
142
|
|
|
124
143
|
existing_class = meta.get_obj_class(class_name)
|
|
125
144
|
if obj_class is None:
|
|
126
|
-
logger.
|
|
145
|
+
logger.warning(f"Object class {class_name} is not in Supervisely format.")
|
|
127
146
|
continue
|
|
128
147
|
if existing_class is None:
|
|
129
148
|
meta = meta.add_obj_class(obj_class)
|
|
@@ -134,6 +153,7 @@ def create_classes_from_annotation(
|
|
|
134
153
|
meta = meta.add_obj_class(obj_class)
|
|
135
154
|
return meta
|
|
136
155
|
|
|
156
|
+
|
|
137
157
|
def rename_in_json(ann_json, renamed_classes=None, renamed_tags=None):
|
|
138
158
|
if renamed_classes:
|
|
139
159
|
for obj in ann_json[OBJECTS]:
|
|
@@ -18,7 +18,7 @@ from fastapi import BackgroundTasks, FastAPI, Form, Request, UploadFile
|
|
|
18
18
|
import supervisely as sly
|
|
19
19
|
import supervisely.io.env as env
|
|
20
20
|
from supervisely._utils import batched
|
|
21
|
-
from supervisely.io.fs import silent_remove
|
|
21
|
+
from supervisely.io.fs import list_files, silent_remove
|
|
22
22
|
from supervisely.video.video import VideoFrameReader
|
|
23
23
|
|
|
24
24
|
|
|
@@ -101,6 +101,10 @@ class PersistentImageTTLCache(TTLCache):
|
|
|
101
101
|
silent_remove(filepath)
|
|
102
102
|
except TypeError:
|
|
103
103
|
pass
|
|
104
|
+
except:
|
|
105
|
+
sly.logger.debug(f"File {filepath} was not deleted from cache", exc_info=True)
|
|
106
|
+
else:
|
|
107
|
+
sly.logger.debug(f"File {filepath} was deleted from cache")
|
|
104
108
|
|
|
105
109
|
def __update_timer(self, key):
|
|
106
110
|
try:
|
|
@@ -135,6 +139,7 @@ class PersistentImageTTLCache(TTLCache):
|
|
|
135
139
|
except TypeError:
|
|
136
140
|
pass
|
|
137
141
|
sly.logger.debug(f"Deleted keys: {deleted}")
|
|
142
|
+
sly.logger.trace(f"Existing files: {list_files(str(self._base_dir))}")
|
|
138
143
|
|
|
139
144
|
def clear(self, rm_base_folder=True) -> None:
|
|
140
145
|
while self.currsize > 0:
|
|
@@ -542,6 +547,7 @@ class InferenceImageCache:
|
|
|
542
547
|
f"Video #{video_id} downloaded to cache in {download_time:.2f} sec",
|
|
543
548
|
extra={"video_id": video_id, "download_time": download_time},
|
|
544
549
|
)
|
|
550
|
+
silent_remove(temp_video_path)
|
|
545
551
|
except Exception as e:
|
|
546
552
|
self._load_queue.delete(video_id)
|
|
547
553
|
raise e
|
|
@@ -619,14 +625,9 @@ class InferenceImageCache:
|
|
|
619
625
|
self.add_frame_to_cache(frame, video_id, frame_index)
|
|
620
626
|
elif task_type is InferenceImageCache._LoadType.Video:
|
|
621
627
|
video_id = image_ids
|
|
622
|
-
temp_video_path = Path("/tmp/smart_cache").joinpath(
|
|
623
|
-
f"_{sly.rand_str(6)}_" + files[0].file.name
|
|
624
|
-
)
|
|
625
|
-
with open(temp_video_path, "wb") as f:
|
|
626
|
-
shutil.copyfileobj(files[0].file, f)
|
|
627
628
|
self._wait_if_in_queue(video_id, sly.logger)
|
|
628
629
|
self._load_queue.set(video_id, video_id)
|
|
629
|
-
self.add_video_to_cache(video_id,
|
|
630
|
+
self.add_video_to_cache(video_id, files[0].file)
|
|
630
631
|
|
|
631
632
|
def run_cache_task_manually(
|
|
632
633
|
self,
|
|
@@ -618,7 +618,7 @@ supervisely/convert/image/pdf/pdf_helper.py,sha256=IDwLEvsVy8lu-KC1lXvSRkZZ9BCC6
|
|
|
618
618
|
supervisely/convert/image/sly/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
619
619
|
supervisely/convert/image/sly/fast_sly_image_converter.py,sha256=r_Nhowicm-oah-XfGEeAOrGNbIzMh63m6ZRYaLKHUu0,5903
|
|
620
620
|
supervisely/convert/image/sly/sly_image_converter.py,sha256=dT7fVivM-u2hhKehGJWPeLsVTi4nW-WX1X6Lktl2mks,14812
|
|
621
|
-
supervisely/convert/image/sly/sly_image_helper.py,sha256=
|
|
621
|
+
supervisely/convert/image/sly/sly_image_helper.py,sha256=CrlDh6E4aLLtva-TbC0pUCA2oi5184dQDecnlm6ty_c,7410
|
|
622
622
|
supervisely/convert/image/yolo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
623
623
|
supervisely/convert/image/yolo/yolo_converter.py,sha256=Wn5dR05y4SEPONcaxWr9ofnbvbf-SbRZN0fkksk5Dps,11391
|
|
624
624
|
supervisely/convert/image/yolo/yolo_helper.py,sha256=5b0ShsVlqikA071VT8AiRW_079_WD6pdB5Bx3OU12Bw,25989
|
|
@@ -667,7 +667,7 @@ supervisely/convert/video/mot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
|
667
667
|
supervisely/convert/video/mot/mot_converter.py,sha256=wXbv-9Psc2uVnhzHuOt5VnRIvSg70NDPQSoKdWwL4Lo,490
|
|
668
668
|
supervisely/convert/video/sly/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
669
669
|
supervisely/convert/video/sly/sly_video_converter.py,sha256=S2qif7JFxqIi9VN_ez_iBtoJXpG9W6Ky2k5Er3-DtUo,4418
|
|
670
|
-
supervisely/convert/video/sly/sly_video_helper.py,sha256=
|
|
670
|
+
supervisely/convert/video/sly/sly_video_helper.py,sha256=sT1Q7RQHkIjNezYASVyLYixLPQdpP0m4Lxzqxa_QXBI,6873
|
|
671
671
|
supervisely/convert/volume/__init__.py,sha256=NaACs000WT2iy_g63TiZZ6IlgCjyDXx6i2OHsGpCYOs,391
|
|
672
672
|
supervisely/convert/volume/volume_converter.py,sha256=3jpt2Yn_G4FSP_vHFsJHQfYNQpT7q6ar_sRyr_xrPnA,5335
|
|
673
673
|
supervisely/convert/volume/dicom/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -892,7 +892,7 @@ supervisely/nn/benchmark/visualization/widgets/sidebar/sidebar.py,sha256=tKPURRS
|
|
|
892
892
|
supervisely/nn/benchmark/visualization/widgets/table/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
893
893
|
supervisely/nn/benchmark/visualization/widgets/table/table.py,sha256=atmDnF1Af6qLQBUjLhK18RMDKAYlxnsuVHMSEa5a-e8,4319
|
|
894
894
|
supervisely/nn/inference/__init__.py,sha256=QFukX2ip-U7263aEPCF_UCFwj6EujbMnsgrXp5Bbt8I,1623
|
|
895
|
-
supervisely/nn/inference/cache.py,sha256=
|
|
895
|
+
supervisely/nn/inference/cache.py,sha256=rfmb1teJ9lNDfisUSh6bwDCVkPZocn8GMvDgLQktnbo,35023
|
|
896
896
|
supervisely/nn/inference/inference.py,sha256=L14M8qGofz6EGrgJvGMcz0h3vsu-AnHPeL_iUO8Kf3Y,195721
|
|
897
897
|
supervisely/nn/inference/inference_request.py,sha256=y6yw0vbaRRcEBS27nq3y0sL6Gmq2qLA_Bm0GrnJGegE,14267
|
|
898
898
|
supervisely/nn/inference/session.py,sha256=dIg2F-OBl68pUzcmtmcI0YQIp1WWNnrJTVMjwFN91Q4,35824
|
|
@@ -1114,9 +1114,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
1114
1114
|
supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
|
|
1115
1115
|
supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
|
|
1116
1116
|
supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
|
|
1117
|
-
supervisely-6.73.
|
|
1118
|
-
supervisely-6.73.
|
|
1119
|
-
supervisely-6.73.
|
|
1120
|
-
supervisely-6.73.
|
|
1121
|
-
supervisely-6.73.
|
|
1122
|
-
supervisely-6.73.
|
|
1117
|
+
supervisely-6.73.402.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
1118
|
+
supervisely-6.73.402.dist-info/METADATA,sha256=tl7MFtsE1JOkbGWKlbfd6PimShaBhNim03vmNuoIekw,35254
|
|
1119
|
+
supervisely-6.73.402.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
1120
|
+
supervisely-6.73.402.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
|
1121
|
+
supervisely-6.73.402.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
|
1122
|
+
supervisely-6.73.402.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|