supervisely 6.73.346__py3-none-any.whl → 6.73.348__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/__init__.py CHANGED
@@ -54,6 +54,7 @@ from supervisely.task.progress import (
54
54
 
55
55
 
56
56
  import supervisely.project as project
57
+ import supervisely.api.constants as api_constants
57
58
  from supervisely.project import read_project, get_project_class
58
59
  from supervisely.project.download import download, download_async, download_fast
59
60
  from supervisely.project.upload import upload
@@ -0,0 +1,3 @@
1
+ # coding: utf-8
2
+
3
+ DOWNLOAD_BATCH_SIZE = None
@@ -55,6 +55,7 @@ from supervisely._utils import (
55
55
  from supervisely.annotation.annotation import Annotation
56
56
  from supervisely.annotation.tag import Tag
57
57
  from supervisely.annotation.tag_meta import TagApplicableTo, TagMeta, TagValueType
58
+ from supervisely.api.constants import DOWNLOAD_BATCH_SIZE
58
59
  from supervisely.api.dataset_api import DatasetInfo
59
60
  from supervisely.api.entity_annotation.figure_api import FigureApi
60
61
  from supervisely.api.entity_annotation.tag_api import TagApi
@@ -368,7 +369,7 @@ class ImageInfo(NamedTuple):
368
369
  #: :class:`int`: ID of the blob file in Supervisely storage related to the image.
369
370
  related_data_id: Optional[int] = None
370
371
 
371
- #: :class:`str`: Unique ID of the image that links it to the corresponding blob file in Supervisely storage
372
+ #: :class:`str`: Unique ID of the image that links it to the corresponding blob file in Supervisely storage
372
373
  #: uses for downloading source blob file.
373
374
  download_id: Optional[str] = None
374
375
 
@@ -1015,7 +1016,14 @@ class ImageApi(RemoveableBulkModuleApi):
1015
1016
  """
1016
1017
  Get image id and it content from given dataset and list of images ids.
1017
1018
  """
1018
- for batch_ids in batched(ids):
1019
+ if DOWNLOAD_BATCH_SIZE is not None and isinstance(DOWNLOAD_BATCH_SIZE, int):
1020
+ batches = batched(ids, DOWNLOAD_BATCH_SIZE)
1021
+ logger.debug(
1022
+ f"Batch size for func 'ImageApi._download_batch' changed to: {DOWNLOAD_BATCH_SIZE}"
1023
+ )
1024
+ else:
1025
+ batches = batched(ids)
1026
+ for batch_ids in batches:
1019
1027
  response = self._api.post(
1020
1028
  "images.bulk.download",
1021
1029
  {ApiField.DATASET_ID: dataset_id, ApiField.IMAGE_IDS: batch_ids},
@@ -2352,7 +2360,9 @@ class ImageApi(RemoveableBulkModuleApi):
2352
2360
 
2353
2361
  for batch in blob_image_infos_generator:
2354
2362
  names = [item.name for item in batch]
2355
- metas_batch = [metas[name] for name in names] if metas is not None else [{}] * len(names)
2363
+ metas_batch = (
2364
+ [metas[name] for name in names] if metas is not None else [{}] * len(names)
2365
+ )
2356
2366
  items = [
2357
2367
  {ApiField.TEAM_FILE_ID: team_file_id, ApiField.SOURCE_BLOB: item.offsets_dict}
2358
2368
  for item in batch
@@ -144,8 +144,8 @@ class MetricProvider:
144
144
  }
145
145
 
146
146
  def get_classwise_error_data(self):
147
- self.eval_data.drop(["mean"], inplace=True)
148
147
  bar_data = self.eval_data.copy()
148
+ bar_data.drop(["mean"], inplace=True)
149
149
  bar_data = bar_data[["IoU", "E_extent_oU", "E_boundary_oU", "E_segment_oU"]]
150
150
  bar_data.sort_values(by="IoU", ascending=False, inplace=True)
151
151
  labels = list(bar_data.index)
@@ -39,7 +39,7 @@ class ConfusionMatrix(SemanticSegmVisMetric):
39
39
  # # Confusion Matrix figure
40
40
  confusion_matrix, class_names = self.eval_result.mp.confusion_matrix
41
41
 
42
- x = class_names
42
+ x = [el for el in class_names if el != "mean"]
43
43
  y = x[::-1].copy()
44
44
  if len(x) >= 20:
45
45
  text_anns = [[str(el) for el in row] for row in confusion_matrix]
@@ -240,6 +240,8 @@ class SemanticSegmentationVisualizer(BaseVisualizer):
240
240
  for src_images in self.api.image.get_list_generator(
241
241
  pred_dataset_info.id, force_metadata_for_links=False, batch_size=100
242
242
  ):
243
+ if len(src_images) == 0:
244
+ continue
243
245
  dst_images = self.api.image.copy_batch_optimized(
244
246
  pred_dataset_info.id,
245
247
  src_images,
@@ -274,8 +276,8 @@ class SemanticSegmentationVisualizer(BaseVisualizer):
274
276
  )
275
277
 
276
278
  p.update(len(src_images))
277
- except Exception:
278
- raise RuntimeError("Match data was not created properly")
279
+ except Exception as e:
280
+ raise RuntimeError(f"Match data was not created properly. {e}")
279
281
 
280
282
  def _get_sample_data_for_gallery(self):
281
283
  # get sample images with annotations for visualization
@@ -1705,8 +1705,38 @@ class Inference:
1705
1705
  if src_dataset_id in new_dataset_id:
1706
1706
  return new_dataset_id[src_dataset_id]
1707
1707
  dataset_info = api.dataset.get_info_by_id(src_dataset_id)
1708
+
1709
+ def _create_parent_recursively(output_project_id, src_parent_id):
1710
+ """Create parent datasets recursively and return the ID of the top-level parent"""
1711
+ if src_parent_id in new_dataset_id:
1712
+ return new_dataset_id[src_parent_id]
1713
+ src_parent_info = dataset_infos_dict.get(src_parent_id)
1714
+ if src_parent_info is None:
1715
+ src_parent_info = api.dataset.get_info_by_id(src_parent_id)
1716
+ if src_parent_info.parent_id is not None:
1717
+ parent_id = _create_parent_recursively(
1718
+ output_project_id, src_parent_info.parent_id
1719
+ )
1720
+ else:
1721
+ parent_id = None
1722
+ dst_parent = api.dataset.create(
1723
+ output_project_id,
1724
+ src_parent_info.name,
1725
+ change_name_if_conflict=True,
1726
+ parent_id=parent_id,
1727
+ )
1728
+ new_dataset_id[src_parent_info.id] = dst_parent.id
1729
+ return dst_parent.id
1730
+
1731
+ parent_id = None
1732
+ if dataset_info.parent_id is not None:
1733
+ parent_id = _create_parent_recursively(output_project_id, dataset_info.parent_id)
1734
+
1708
1735
  output_dataset_id = api.dataset.create(
1709
- output_project_id, dataset_info.name, change_name_if_conflict=True
1736
+ output_project_id,
1737
+ dataset_info.name,
1738
+ change_name_if_conflict=True,
1739
+ parent_id=parent_id,
1710
1740
  ).id
1711
1741
  new_dataset_id[src_dataset_id] = output_dataset_id
1712
1742
  return output_dataset_id
@@ -284,8 +284,64 @@ def download_fast(
284
284
  Download project in a fast mode.
285
285
  Items are downloaded asynchronously. If an error occurs, the method will fallback to synchronous download.
286
286
  Automatically detects project type.
287
- You can pass :class:`ProjectInfo` as `project_info` kwarg to avoid additional API requests.
287
+
288
+ :param api: Supervisely API address and token.
289
+ :type api: :class:`Api<supervisely.api.api.Api>`
290
+ :param project_id: Supervisely downloadable project ID.
291
+ :type project_id: :class:`int`
292
+ :param dest_dir: Destination directory.
293
+ :type dest_dir: :class:`str`
294
+ :param dataset_ids: Filter datasets by IDs.
295
+ :type dataset_ids: :class:`list` [ :class:`int` ], optional
296
+ :param log_progress: Show uploading progress bar.
297
+ :type log_progress: :class:`bool`
298
+ :param progress_cb: Function for tracking download progress.
299
+ :type progress_cb: tqdm or callable, optional
300
+ :param semaphore: Semaphore to limit the number of concurrent downloads of items.
301
+ :type semaphore: :class:`asyncio.Semaphore`, optional
302
+ :param only_image_tags: Download project with only images tags (without objects tags).
303
+ :type only_image_tags: :class:`bool`, optional
304
+ :param save_image_info: Download images infos or not.
305
+ :type save_image_info: :class:`bool`, optional
306
+ :param save_images: Download images or not.
307
+ :type save_images: :class:`bool`, optional
308
+ :param save_image_meta: Download images metadata in JSON format or not.
309
+ :type save_image_meta: :class:`bool`, optional
310
+ :param images_ids: Filter images by IDs.
311
+ :type images_ids: :class:`list` [ :class:`int` ], optional
312
+ :param resume_download: Resume download enables to download only missing files avoiding erase of existing files.
313
+ :type resume_download: :class:`bool`, optional
314
+ :param switch_size: Size threshold that determines how an item will be downloaded.
315
+ Items larger than this size will be downloaded as single files, while smaller items will be downloaded as a batch.
316
+ Useful for projects with different item sizes and when you exactly know which size will perform better with batch download.
317
+ :type switch_size: :class:`int`, optional
318
+ :param batch_size: Number of items to download in a single batch.
319
+ :type batch_size: :class:`int`, optional
320
+ :param download_blob_files: Download project with Blob files in native format.
321
+ If False - download project like a regular project in classic Supervisely format.
322
+ :type download_blob_files: :class:`bool`, optional
323
+ :param project_info: Project info object. To avoid additional API requests.
324
+ :type project_info: :class:`ProjectInfo`, optional
325
+ :return: None
326
+ :rtype: NoneType
327
+
328
+ :Usage example:
329
+
330
+ .. code-block:: python
331
+
332
+ import supervisely as sly
333
+
334
+ os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
335
+ os.environ['API_TOKEN'] = 'Your Supervisely API Token'
336
+ api = sly.Api.from_env()
337
+
338
+ project_id = 8888
339
+ save_directory = "/path/to/save/projects"
340
+
341
+ sly.download_fast(api, project_id, save_directory)
342
+
288
343
  """
344
+
289
345
  download_async_or_sync(
290
346
  api=api,
291
347
  project_id=project_id,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supervisely
3
- Version: 6.73.346
3
+ Version: 6.73.348
4
4
  Summary: Supervisely Python SDK.
5
5
  Home-page: https://github.com/supervisely/supervisely
6
6
  Author: Supervisely
@@ -1,5 +1,5 @@
1
1
  supervisely/README.md,sha256=XM-DiMC6To3I9RjQZ0c61905EFRR_jnCUx2q3uNR-X8,3331
2
- supervisely/__init__.py,sha256=mVZ34ziMzw-Hlr5kaTt1xSh5VZIWrTgTNeSyLKcrOyI,10867
2
+ supervisely/__init__.py,sha256=_qphKFT0_toEQmF5IjB1sWjztbF4lP1tLY29PBJhArY,10917
3
3
  supervisely/_utils.py,sha256=DA-sPMk68GyInrc4DMxO-Azp5-uWkwZx_NAr8mXVI0o,18280
4
4
  supervisely/function_wrapper.py,sha256=R5YajTQ0GnRp2vtjwfC9hINkzQc0JiyGsu8TER373xY,1912
5
5
  supervisely/sly_logger.py,sha256=z92Vu5hmC0GgTIJO1n6kPDayRW9__8ix8hL6poDZj-Y,6274
@@ -24,11 +24,12 @@ supervisely/api/agent_api.py,sha256=ShWAIlXcWXcyI9fqVuP5GZVCigCMJmjnvdGUfLspD6Y,
24
24
  supervisely/api/annotation_api.py,sha256=XE3Sr_oQOMraZ9NlWs9ZqUsff1j47XRDh9Fy8rW4ubw,82763
25
25
  supervisely/api/api.py,sha256=D90G6ivwyHHK7WVo4ByKtv65lSED_Sm1qlp_TpyCeAc,67398
26
26
  supervisely/api/app_api.py,sha256=RsbVej8WxWVn9cNo5s3Fqd1symsCdsfOaKVBKEUapRY,71927
27
+ supervisely/api/constants.py,sha256=qwK9Q3mHGz5Ny5WuBmPQgawBWfzCT2DRiw3IcaCDRmo,44
27
28
  supervisely/api/dataset_api.py,sha256=c6rEVySSxbyDB5fUCilsc5AKk0pWN_5vVN6OceDbEvc,47918
28
29
  supervisely/api/file_api.py,sha256=EX_Cam93QkR5SOOIkIznkzERIr0u7N7GHVGK27iOm20,92952
29
30
  supervisely/api/github_api.py,sha256=NIexNjEer9H5rf5sw2LEZd7C1WR-tK4t6IZzsgeAAwQ,623
30
31
  supervisely/api/image_annotation_tool_api.py,sha256=YcUo78jRDBJYvIjrd-Y6FJAasLta54nnxhyaGyanovA,5237
31
- supervisely/api/image_api.py,sha256=pPY8K4hKKE4hvWNB6VEXd-AypSCqrivCWWsHDQKKu6g,223223
32
+ supervisely/api/image_api.py,sha256=sE2lIPPYLv1tJsuFSjc9IvLVB07kmq9PnPodU3J6aEs,223637
32
33
  supervisely/api/import_storage_api.py,sha256=BDCgmR0Hv6OoiRHLCVPKt3iDxSVlQp1WrnKhAK_Zl84,460
33
34
  supervisely/api/issues_api.py,sha256=BqDJXmNoTzwc3xe6_-mA7FDFC5QQ-ahGbXk_HmpkSeQ,17925
34
35
  supervisely/api/labeling_job_api.py,sha256=VM1pjM65cUTeer1hrI7cSmCUOHJb7fzK6gJ-abA07hg,55097
@@ -826,13 +827,13 @@ supervisely/nn/benchmark/semantic_segmentation/base_vis_metric.py,sha256=mwGjRUT
826
827
  supervisely/nn/benchmark/semantic_segmentation/benchmark.py,sha256=8rnU6I94q0GUdXWwluZu0_Sac_eU2-Az133tHF1dA3U,1202
827
828
  supervisely/nn/benchmark/semantic_segmentation/evaluation_params.yaml,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
828
829
  supervisely/nn/benchmark/semantic_segmentation/evaluator.py,sha256=XafPMpGL6v0ZQ-m7DkEjoY7W6fGCJNKolql5BA3M8V0,7261
829
- supervisely/nn/benchmark/semantic_segmentation/metric_provider.py,sha256=GwdRvyG0_nFpng6jN8ISFcMLfDbBd-fwdtoWR2XPKw4,6552
830
+ supervisely/nn/benchmark/semantic_segmentation/metric_provider.py,sha256=478l7w2n-yueBMVABsakfIQEo3MksbCYmKNrwMFOl6w,6546
830
831
  supervisely/nn/benchmark/semantic_segmentation/text_templates.py,sha256=7yRRD2FAdJHGSRqBVIjNjzCduKzaepA1OWtggi7B0Dg,8580
831
- supervisely/nn/benchmark/semantic_segmentation/visualizer.py,sha256=Nt2-OOWKQ8fbaXFk5QeEaMtMURKPQebgjzDytVgQk0g,13196
832
+ supervisely/nn/benchmark/semantic_segmentation/visualizer.py,sha256=T7WTjnyFLL3BAyH7yQIqI6R5VNj1M3guamwhDglOegE,13293
832
833
  supervisely/nn/benchmark/semantic_segmentation/vis_metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
833
834
  supervisely/nn/benchmark/semantic_segmentation/vis_metrics/acknowledgement.py,sha256=Lm82x8AIMKv1WqmqA0W9fugSlQ_JrP9dwYYYReZmhvI,440
834
835
  supervisely/nn/benchmark/semantic_segmentation/vis_metrics/classwise_error_analysis.py,sha256=0bmL43a4cqw3grFoG68NN8Y1fkRpHBIRJptcxMor-78,1884
835
- supervisely/nn/benchmark/semantic_segmentation/vis_metrics/confusion_matrix.py,sha256=xpvicxgwDaih-64VSAsxdNvoFxeA_iaUGOK9gpvNyuQ,3233
836
+ supervisely/nn/benchmark/semantic_segmentation/vis_metrics/confusion_matrix.py,sha256=nhfUPQr1dmZpYSluVX2XmMLk8AxzahKl2hcvGEXx9oQ,3264
836
837
  supervisely/nn/benchmark/semantic_segmentation/vis_metrics/explore_predictions.py,sha256=QVtcGQv4S8W7jLANUsvuJaPP-OrUQ_LB2oEpjpLBecw,2936
837
838
  supervisely/nn/benchmark/semantic_segmentation/vis_metrics/frequently_confused.py,sha256=SyVgMD66EFLfgrClb5RCJjLhgRfTYqGsUORPYIuSe58,3697
838
839
  supervisely/nn/benchmark/semantic_segmentation/vis_metrics/iou_eou.py,sha256=IdUho3712dDLyVsgR01aNSQBcraPzYwpJmTc9AB0Txw,1401
@@ -883,7 +884,7 @@ supervisely/nn/benchmark/visualization/widgets/table/__init__.py,sha256=47DEQpj8
883
884
  supervisely/nn/benchmark/visualization/widgets/table/table.py,sha256=atmDnF1Af6qLQBUjLhK18RMDKAYlxnsuVHMSEa5a-e8,4319
884
885
  supervisely/nn/inference/__init__.py,sha256=QFukX2ip-U7263aEPCF_UCFwj6EujbMnsgrXp5Bbt8I,1623
885
886
  supervisely/nn/inference/cache.py,sha256=LAirR5mFHCtK59EO1lefQ2qhpp0vBvRTH26EVrs13Y0,32073
886
- supervisely/nn/inference/inference.py,sha256=qBAItRxn1wZoNxSZNY6bCcaUKwwowFlRaF_z4l-c7TY,169955
887
+ supervisely/nn/inference/inference.py,sha256=6rwm4Xbar-acekOV26k0JRsKR7u9zexayOEWg6IM-yY,171299
887
888
  supervisely/nn/inference/session.py,sha256=jmkkxbe2kH-lEgUU6Afh62jP68dxfhF5v6OGDfLU62E,35757
888
889
  supervisely/nn/inference/video_inference.py,sha256=8Bshjr6rDyLay5Za8IB8Dr6FURMO2R_v7aELasO8pR4,5746
889
890
  supervisely/nn/inference/gui/__init__.py,sha256=wCxd-lF5Zhcwsis-wScDA8n1Gk_1O00PKgDviUZ3F1U,221
@@ -1017,7 +1018,7 @@ supervisely/pointcloud_episodes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
1017
1018
  supervisely/pointcloud_episodes/pointcloud_episodes.py,sha256=cRXdtw7bMsbsdVQjxfWxFSESrO-LGiqqsZyyExl2Mbg,3430
1018
1019
  supervisely/project/__init__.py,sha256=hlzdj9Pgy53Q3qdP8LMtGTChvZHQuuShdtui2eRUQeE,2601
1019
1020
  supervisely/project/data_version.py,sha256=P5Lui6i64pYeJWmAdGJDv8GRXxjfpSSZ8zT_MxIrynE,19553
1020
- supervisely/project/download.py,sha256=4QOEQZnolmOpEO6Wl6DIc73BwIYr9m-6anbarrU6VwQ,24902
1021
+ supervisely/project/download.py,sha256=N6UEXY_eLtzjz61Y2SaJLg2-vv_Cvp9cXCUUM9R8-d8,27677
1021
1022
  supervisely/project/pointcloud_episode_project.py,sha256=yiWdNBQiI6f1O9sr1pg8JHW6O-w3XUB1rikJNn3Oung,41866
1022
1023
  supervisely/project/pointcloud_project.py,sha256=Kx1Vaes-krwG3BiRRtHRLQxb9G5m5bTHPN9IzRqmNWo,49399
1023
1024
  supervisely/project/project.py,sha256=OunVB11sVQSOvkqkjsEEkX1nq9OUXOXpHTdcLDjOFe0,233256
@@ -1082,9 +1083,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
1082
1083
  supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
1083
1084
  supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
1084
1085
  supervisely_lib/__init__.py,sha256=7-3QnN8Zf0wj8NCr2oJmqoQWMKKPKTECvjH9pd2S5vY,159
1085
- supervisely-6.73.346.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1086
- supervisely-6.73.346.dist-info/METADATA,sha256=yUMHQ-WdsvhuLAX9ZHWWh3fgUDTlkNR36oZaRpzRHf8,33596
1087
- supervisely-6.73.346.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
1088
- supervisely-6.73.346.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1089
- supervisely-6.73.346.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1090
- supervisely-6.73.346.dist-info/RECORD,,
1086
+ supervisely-6.73.348.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1087
+ supervisely-6.73.348.dist-info/METADATA,sha256=Heozuyuf1zukvQzantkbHHyMXh1S4WnVFvWm0p4JIE8,33596
1088
+ supervisely-6.73.348.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
1089
+ supervisely-6.73.348.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1090
+ supervisely-6.73.348.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1091
+ supervisely-6.73.348.dist-info/RECORD,,