supervisely 6.73.235__py3-none-any.whl → 6.73.237__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/api/image_api.py +147 -1
- {supervisely-6.73.235.dist-info → supervisely-6.73.237.dist-info}/METADATA +7 -7
- {supervisely-6.73.235.dist-info → supervisely-6.73.237.dist-info}/RECORD +7 -7
- {supervisely-6.73.235.dist-info → supervisely-6.73.237.dist-info}/LICENSE +0 -0
- {supervisely-6.73.235.dist-info → supervisely-6.73.237.dist-info}/WHEEL +0 -0
- {supervisely-6.73.235.dist-info → supervisely-6.73.237.dist-info}/entry_points.txt +0 -0
- {supervisely-6.73.235.dist-info → supervisely-6.73.237.dist-info}/top_level.txt +0 -0
supervisely/api/image_api.py
CHANGED
|
@@ -3126,6 +3126,7 @@ class ImageApi(RemoveableBulkModuleApi):
|
|
|
3126
3126
|
progress_cb: Optional[Union[tqdm, Callable]] = None,
|
|
3127
3127
|
links: Optional[List[str]] = None,
|
|
3128
3128
|
conflict_resolution: Optional[Literal["rename", "skip", "replace"]] = "rename",
|
|
3129
|
+
force_metadata_for_links: Optional[bool] = False,
|
|
3129
3130
|
) -> List[ImageInfo]:
|
|
3130
3131
|
"""
|
|
3131
3132
|
Uploads images to Supervisely and adds a tag to them.
|
|
@@ -3153,6 +3154,9 @@ class ImageApi(RemoveableBulkModuleApi):
|
|
|
3153
3154
|
- 'skip': Ignores uploading the new images if there is a conflict; the original image's ImageInfo list will be returned instead.
|
|
3154
3155
|
- 'rename': (default) Renames the new images to prevent name conflicts.
|
|
3155
3156
|
:type conflict_resolution: Optional[Literal["rename", "skip", "replace"]]
|
|
3157
|
+
:param force_metadata_for_links: Specifies whether to force retrieving metadata for images from links.
|
|
3158
|
+
If False, metadata fields in the response can be empty (if metadata has not been retrieved yet).
|
|
3159
|
+
:type force_metadata_for_links: Optional[bool]
|
|
3156
3160
|
:return: List of uploaded images infos
|
|
3157
3161
|
:rtype: List[ImageInfo]
|
|
3158
3162
|
:raises Exception: if tag does not exist in project or tag is not of type ANY_STRING
|
|
@@ -3215,6 +3219,7 @@ class ImageApi(RemoveableBulkModuleApi):
|
|
|
3215
3219
|
links=links,
|
|
3216
3220
|
progress_cb=progress_cb,
|
|
3217
3221
|
conflict_resolution=conflict_resolution,
|
|
3222
|
+
force_metadata_for_links=force_metadata_for_links,
|
|
3218
3223
|
)
|
|
3219
3224
|
image_infos.extend(image_infos_by_links)
|
|
3220
3225
|
|
|
@@ -3223,10 +3228,151 @@ class ImageApi(RemoveableBulkModuleApi):
|
|
|
3223
3228
|
self._api.annotation.upload_anns(image_ids, anns)
|
|
3224
3229
|
|
|
3225
3230
|
uploaded_image_infos = self.get_list(
|
|
3226
|
-
dataset_id,
|
|
3231
|
+
dataset_id,
|
|
3232
|
+
filters=[
|
|
3233
|
+
{
|
|
3234
|
+
ApiField.FIELD: ApiField.ID,
|
|
3235
|
+
ApiField.OPERATOR: "in",
|
|
3236
|
+
ApiField.VALUE: image_ids,
|
|
3237
|
+
}
|
|
3238
|
+
],
|
|
3239
|
+
force_metadata_for_links=force_metadata_for_links,
|
|
3227
3240
|
)
|
|
3228
3241
|
return uploaded_image_infos
|
|
3229
3242
|
|
|
3243
|
+
def group_images_for_multiview(
|
|
3244
|
+
self,
|
|
3245
|
+
image_ids: List[int],
|
|
3246
|
+
group_name: str,
|
|
3247
|
+
multiview_tag_name: Optional[str] = None,
|
|
3248
|
+
) -> None:
|
|
3249
|
+
"""
|
|
3250
|
+
Group images for multi-view by tag with given name. If tag does not exist in project, will create it first.
|
|
3251
|
+
|
|
3252
|
+
Note:
|
|
3253
|
+
* All images must belong to the same project.
|
|
3254
|
+
* Tag must be of type ANY_STRING and applicable to images.
|
|
3255
|
+
* Recommended number of images in group is 6-12.
|
|
3256
|
+
|
|
3257
|
+
:param image_ids: List of Images IDs in Supervisely.
|
|
3258
|
+
:type image_ids: List[int]
|
|
3259
|
+
:param group_name: Group name. Images will be assigned by group tag with this value.
|
|
3260
|
+
:type group_name: str
|
|
3261
|
+
:param multiview_tag_name: Multiview tag name in Supervisely.
|
|
3262
|
+
If None, will use default 'multiview' tag name.
|
|
3263
|
+
If tag does not exist in project, will create it first.
|
|
3264
|
+
:type multiview_tag_name: str, optional
|
|
3265
|
+
:return: :class:`None<None>`
|
|
3266
|
+
|
|
3267
|
+
:rtype: :class:`NoneType<NoneType>`
|
|
3268
|
+
:raises ValueError: if tag is not of type ANY_STRING or not applicable to images
|
|
3269
|
+
|
|
3270
|
+
:Usage example:
|
|
3271
|
+
|
|
3272
|
+
.. code-block:: python
|
|
3273
|
+
|
|
3274
|
+
# ? option 1
|
|
3275
|
+
import supervisely as sly
|
|
3276
|
+
|
|
3277
|
+
os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
|
|
3278
|
+
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
|
|
3279
|
+
api = sly.Api.from_env()
|
|
3280
|
+
|
|
3281
|
+
BATCH_SIZE = 6
|
|
3282
|
+
image_ids = [2389126, 2389127, 2389128, 2389129, 2389130, 2389131, ...]
|
|
3283
|
+
|
|
3284
|
+
# group images for multiview
|
|
3285
|
+
for group_name, ids in enumerate(sly.batched(image_ids, batch_size=BATCH_SIZE)):
|
|
3286
|
+
api.image.group_images_for_multiview(ids, group_name)
|
|
3287
|
+
|
|
3288
|
+
|
|
3289
|
+
# ? option 2 (with sly.ApiContext)
|
|
3290
|
+
import supervisely as sly
|
|
3291
|
+
|
|
3292
|
+
os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
|
|
3293
|
+
os.environ['API_TOKEN'] = 'Your Supervisely API Token'
|
|
3294
|
+
api = sly.Api.from_env()
|
|
3295
|
+
|
|
3296
|
+
BATCH_SIZE = 6
|
|
3297
|
+
image_ids = [2389126, 2389127, 2389128, 2389129, 2389130, 2389131, ...]
|
|
3298
|
+
project_id = 111111 # change to your project id
|
|
3299
|
+
|
|
3300
|
+
|
|
3301
|
+
# * make sure that `with_settings=True` is set to get project settings from server
|
|
3302
|
+
project_meta_json = api.project.get_meta(project_id, with_settings=True)
|
|
3303
|
+
project_meta = sly.ProjectMeta.from_json(project_meta_json)
|
|
3304
|
+
|
|
3305
|
+
# create custom tag meta (optional)
|
|
3306
|
+
multiview_tag_name = 'cars'
|
|
3307
|
+
tag_meta = sly.TagMeta(multiview_tag_name, sly.TagValueType.ANY_STRING)
|
|
3308
|
+
project_meta = project_meta.add_tag_meta(tag_meta)
|
|
3309
|
+
project_meta = api.project.update_meta(project_id, project_meta) # update meta on server
|
|
3310
|
+
|
|
3311
|
+
# group images for multiview
|
|
3312
|
+
with sly.ApiContext(api, project_id=project_id, project_meta=project_meta):
|
|
3313
|
+
for group_name, ids in enumerate(sly.batched(image_ids, batch_size=BATCH_SIZE)):
|
|
3314
|
+
api.image.group_images_for_multiview(ids, group_name, multiview_tag_name)
|
|
3315
|
+
|
|
3316
|
+
"""
|
|
3317
|
+
|
|
3318
|
+
# ============= Api Context ===================================
|
|
3319
|
+
# using context for optimization (avoiding extra API requests)
|
|
3320
|
+
context = self._api.optimization_context
|
|
3321
|
+
project_meta = context.get("project_meta")
|
|
3322
|
+
project_id = context.get("project_id")
|
|
3323
|
+
if project_id is None:
|
|
3324
|
+
project_id = self.get_project_id(image_ids[0])
|
|
3325
|
+
context["project_id"] = project_id
|
|
3326
|
+
if project_meta is None:
|
|
3327
|
+
project_meta = ProjectMeta.from_json(
|
|
3328
|
+
self._api.project.get_meta(project_id, with_settings=True)
|
|
3329
|
+
)
|
|
3330
|
+
context["project_meta"] = project_meta
|
|
3331
|
+
# =============================================================
|
|
3332
|
+
|
|
3333
|
+
need_update_project_meta = False
|
|
3334
|
+
multiview_tag_name = multiview_tag_name or _MULTIVIEW_TAG_NAME
|
|
3335
|
+
multiview_tag_meta = project_meta.get_tag_meta(multiview_tag_name)
|
|
3336
|
+
|
|
3337
|
+
if multiview_tag_meta is None:
|
|
3338
|
+
multiview_tag_meta = TagMeta(
|
|
3339
|
+
multiview_tag_name,
|
|
3340
|
+
TagValueType.ANY_STRING,
|
|
3341
|
+
applicable_to=TagApplicableTo.IMAGES_ONLY,
|
|
3342
|
+
)
|
|
3343
|
+
project_meta = project_meta.add_tag_meta(multiview_tag_meta)
|
|
3344
|
+
need_update_project_meta = True
|
|
3345
|
+
elif multiview_tag_meta.sly_id is None:
|
|
3346
|
+
logger.warning(f"`sly_id` is None for group tag, trying to get it from server")
|
|
3347
|
+
need_update_project_meta = True
|
|
3348
|
+
|
|
3349
|
+
if multiview_tag_meta.value_type != TagValueType.ANY_STRING:
|
|
3350
|
+
raise ValueError(f"Tag '{multiview_tag_name}' is not of type ANY_STRING.")
|
|
3351
|
+
elif multiview_tag_meta.applicable_to == TagApplicableTo.OBJECTS_ONLY:
|
|
3352
|
+
raise ValueError(f"Tag '{multiview_tag_name}' is not applicable to images.")
|
|
3353
|
+
|
|
3354
|
+
if need_update_project_meta:
|
|
3355
|
+
project_meta = self._api.project.update_meta(id=project_id, meta=project_meta)
|
|
3356
|
+
context["project_meta"] = project_meta
|
|
3357
|
+
multiview_tag_meta = project_meta.get_tag_meta(multiview_tag_name)
|
|
3358
|
+
|
|
3359
|
+
if not project_meta.project_settings.multiview_enabled:
|
|
3360
|
+
if multiview_tag_name == _MULTIVIEW_TAG_NAME:
|
|
3361
|
+
self._api.project.set_multiview_settings(project_id)
|
|
3362
|
+
else:
|
|
3363
|
+
self._api.project._set_custom_grouping_settings(
|
|
3364
|
+
id=project_id,
|
|
3365
|
+
group_images=True,
|
|
3366
|
+
tag_name=multiview_tag_name,
|
|
3367
|
+
sync=False,
|
|
3368
|
+
)
|
|
3369
|
+
project_meta = ProjectMeta.from_json(
|
|
3370
|
+
self._api.project.get_meta(project_id, with_settings=True)
|
|
3371
|
+
)
|
|
3372
|
+
context["project_meta"] = project_meta
|
|
3373
|
+
|
|
3374
|
+
self.add_tag_batch(image_ids, multiview_tag_meta.sly_id, group_name)
|
|
3375
|
+
|
|
3230
3376
|
def upload_medical_images(
|
|
3231
3377
|
self,
|
|
3232
3378
|
dataset_id: int,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: supervisely
|
|
3
|
-
Version: 6.73.
|
|
3
|
+
Version: 6.73.237
|
|
4
4
|
Summary: Supervisely Python SDK.
|
|
5
5
|
Home-page: https://github.com/supervisely/supervisely
|
|
6
6
|
Author: Supervisely
|
|
@@ -22,10 +22,10 @@ Description-Content-Type: text/markdown
|
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
Requires-Dist: cachetools<=5.5.0,>=4.2.3
|
|
24
24
|
Requires-Dist: numpy<2.0.0,>=1.19
|
|
25
|
-
Requires-Dist: opencv-python<5.0.0.0,>=4.
|
|
25
|
+
Requires-Dist: opencv-python<5.0.0.0,>=4.6.0.66
|
|
26
26
|
Requires-Dist: PTable<1.0.0,>=0.9.2
|
|
27
27
|
Requires-Dist: pillow<=10.2.0,>=5.4.1
|
|
28
|
-
Requires-Dist: protobuf<=3.20.3,>=3.
|
|
28
|
+
Requires-Dist: protobuf<=3.20.3,>=3.19.5
|
|
29
29
|
Requires-Dist: python-json-logger<3.0.0,>=0.1.11
|
|
30
30
|
Requires-Dist: requests<3.0.0,>=2.27.1
|
|
31
31
|
Requires-Dist: requests-toolbelt>=0.9.1
|
|
@@ -52,7 +52,7 @@ Requires-Dist: arel<1.0.0,>=0.2.0
|
|
|
52
52
|
Requires-Dist: tqdm<5.0.0,>=4.62.3
|
|
53
53
|
Requires-Dist: pandas<=2.1.4,>=1.1.3
|
|
54
54
|
Requires-Dist: async-asgi-testclient
|
|
55
|
-
Requires-Dist: PyYAML
|
|
55
|
+
Requires-Dist: PyYAML>=5.4.0
|
|
56
56
|
Requires-Dist: distinctipy
|
|
57
57
|
Requires-Dist: beautifulsoup4
|
|
58
58
|
Requires-Dist: numerize
|
|
@@ -98,7 +98,7 @@ Requires-Dist: imagecorruptions<2.0.0,>=1.1.2; extra == "extras"
|
|
|
98
98
|
Requires-Dist: scikit-image<1.0.0,>=0.17.1; extra == "extras"
|
|
99
99
|
Requires-Dist: matplotlib<4.0.0,>=3.3.2; extra == "extras"
|
|
100
100
|
Requires-Dist: pascal-voc-writer<1.0.0,>=0.1.4; extra == "extras"
|
|
101
|
-
Requires-Dist: scipy<2.0.0,>=1.
|
|
101
|
+
Requires-Dist: scipy<2.0.0,>=1.8.0; extra == "extras"
|
|
102
102
|
Requires-Dist: pandas<1.4.0,>=1.1.3; extra == "extras"
|
|
103
103
|
Requires-Dist: ruamel.yaml==0.17.21; extra == "extras"
|
|
104
104
|
Provides-Extra: model-benchmark
|
|
@@ -111,13 +111,13 @@ Provides-Extra: sdk-nn-plugins
|
|
|
111
111
|
Requires-Dist: flask-restful<1.0.0,>=0.3.7; extra == "sdk-nn-plugins"
|
|
112
112
|
Requires-Dist: Werkzeug<3.0.0,>=1.0.1; extra == "sdk-nn-plugins"
|
|
113
113
|
Provides-Extra: sdk-no-usages
|
|
114
|
-
Requires-Dist: grpcio<2.0.0,>=1.
|
|
114
|
+
Requires-Dist: grpcio<2.0.0,>=1.53.2; extra == "sdk-no-usages"
|
|
115
115
|
Requires-Dist: plotly<6.0.0,>=4.11.0; extra == "sdk-no-usages"
|
|
116
116
|
Requires-Dist: psutil<6.0.0,>=5.4.5; extra == "sdk-no-usages"
|
|
117
117
|
Provides-Extra: tracking
|
|
118
118
|
Requires-Dist: yacs; extra == "tracking"
|
|
119
119
|
Requires-Dist: matplotlib<4.0.0,>=3.3.2; extra == "tracking"
|
|
120
|
-
Requires-Dist: scipy<2.0.0,>=1.
|
|
120
|
+
Requires-Dist: scipy<2.0.0,>=1.8.0; extra == "tracking"
|
|
121
121
|
Requires-Dist: lap; extra == "tracking"
|
|
122
122
|
Requires-Dist: cython-bbox; extra == "tracking"
|
|
123
123
|
Requires-Dist: termcolor; extra == "tracking"
|
|
@@ -28,7 +28,7 @@ supervisely/api/dataset_api.py,sha256=2-SQBlgEnIN-0uvDbtPlSXr6ztBeZ3WPryhkOtpBmk
|
|
|
28
28
|
supervisely/api/file_api.py,sha256=WMg80fxqMKOo3ai-IGON2w-IDAySPk90USoVk29JOdE,82415
|
|
29
29
|
supervisely/api/github_api.py,sha256=NIexNjEer9H5rf5sw2LEZd7C1WR-tK4t6IZzsgeAAwQ,623
|
|
30
30
|
supervisely/api/image_annotation_tool_api.py,sha256=YcUo78jRDBJYvIjrd-Y6FJAasLta54nnxhyaGyanovA,5237
|
|
31
|
-
supervisely/api/image_api.py,sha256=
|
|
31
|
+
supervisely/api/image_api.py,sha256=_wXn10tKKCcfvTiQax0O2X9lnE54nXucwQHTjA1WbRM,169172
|
|
32
32
|
supervisely/api/import_storage_api.py,sha256=BDCgmR0Hv6OoiRHLCVPKt3iDxSVlQp1WrnKhAK_Zl84,460
|
|
33
33
|
supervisely/api/issues_api.py,sha256=BqDJXmNoTzwc3xe6_-mA7FDFC5QQ-ahGbXk_HmpkSeQ,17925
|
|
34
34
|
supervisely/api/labeling_job_api.py,sha256=odnzZjp29yM16Gq-FYkv-OA4WFMNJCLFo4qSikW2A7c,56280
|
|
@@ -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.
|
|
1001
|
-
supervisely-6.73.
|
|
1002
|
-
supervisely-6.73.
|
|
1003
|
-
supervisely-6.73.
|
|
1004
|
-
supervisely-6.73.
|
|
1005
|
-
supervisely-6.73.
|
|
1000
|
+
supervisely-6.73.237.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
1001
|
+
supervisely-6.73.237.dist-info/METADATA,sha256=irWoZLS-SE5T_D_g2d6eiZcANw9CGa0r2OH7R8CvoSQ,33157
|
|
1002
|
+
supervisely-6.73.237.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
1003
|
+
supervisely-6.73.237.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
|
|
1004
|
+
supervisely-6.73.237.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
|
|
1005
|
+
supervisely-6.73.237.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|