supervisely 6.73.216__py3-none-any.whl → 6.73.218__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.

@@ -2629,7 +2629,7 @@ class ImageApi(RemoveableBulkModuleApi):
2629
2629
  """
2630
2630
  return resize_image_url(url, ext, method, width, height, quality)
2631
2631
 
2632
- def update_meta(self, id: int, meta: Dict) -> Dict:
2632
+ def update_meta(self, id: int, meta: Dict) -> Dict[str, Any]:
2633
2633
  """
2634
2634
  It is possible to add custom JSON data to every image for storing some additional information.
2635
2635
  Updates Image metadata by ID. Metadata is visible in Labeling Tool.
@@ -2669,10 +2669,93 @@ class ImageApi(RemoveableBulkModuleApi):
2669
2669
  # "Focal Length": "16 mm"
2670
2670
  # }
2671
2671
  """
2672
- if type(meta) is not dict:
2673
- raise TypeError("Meta must be dict, not {}".format(type(meta)))
2674
- response = self._api.post("images.editInfo", {ApiField.ID: id, ApiField.META: meta})
2675
- return response.json()
2672
+ return self.edit(id=id, meta=meta, return_json=True)
2673
+
2674
+ def edit(
2675
+ self,
2676
+ id: int,
2677
+ name: Optional[str] = None,
2678
+ description: Optional[str] = None,
2679
+ meta: Optional[Dict] = None,
2680
+ return_json: bool = False,
2681
+ ) -> Union[ImageInfo, Dict[str, Any]]:
2682
+ """Updates the information about the image by given ID with provided parameters.
2683
+ At least one parameter must be set, otherwise ValueError will be raised.
2684
+
2685
+ :param id: Image ID in Supervisely.
2686
+ :type id: int
2687
+ :param name: New Image name.
2688
+ :type name: str, optional
2689
+ :param description: New Image description.
2690
+ :type description: str, optional
2691
+ :param meta: New Image metadata.
2692
+ :type meta: dict, optional
2693
+ :return_json: If True, return response in JSON format, otherwise convert it ImageInfo object.
2694
+ This parameter is only added for backward compatibility for update_meta method.
2695
+ It's not recommended to use it in new code.
2696
+ :type return_json: bool, optional
2697
+ :raises: :class:`ValueError` if at least one parameter is not set
2698
+ :raises: :class:`ValueError if meta parameter was set and it is not a dictionary
2699
+ :return: Information about updated image as ImageInfo object or as dict if return_json is True
2700
+ :rtype: :class:`ImageInfo` or :class:`dict`
2701
+
2702
+ :Usage example:
2703
+
2704
+ .. code-block:: python
2705
+
2706
+ import supervisely as sly
2707
+
2708
+ api = sly.Api.from_env()
2709
+
2710
+ image_id = 123456
2711
+ new_image_name = "IMG_3333_new.jpg"
2712
+
2713
+ api.image.edit(id=image_id, name=new_image_name)
2714
+ """
2715
+ if name is None and description is None and meta is None:
2716
+ raise ValueError("At least one parameter must be set")
2717
+
2718
+ if meta is not None and not isinstance(meta, dict):
2719
+ raise ValueError("meta parameter must be a dictionary")
2720
+
2721
+ data = {
2722
+ ApiField.ID: id,
2723
+ ApiField.NAME: name,
2724
+ ApiField.DESCRIPTION: description,
2725
+ ApiField.META: meta,
2726
+ }
2727
+ data = {k: v for k, v in data.items() if v is not None}
2728
+
2729
+ response = self._api.post("images.editInfo", data)
2730
+ if return_json:
2731
+ return response.json()
2732
+ return self._convert_json_info(response.json(), skip_missing=True)
2733
+
2734
+ def rename(self, id: int, name: str) -> ImageInfo:
2735
+ """
2736
+ Renames Image with given ID.
2737
+
2738
+ :param id: Image ID in Supervisely.
2739
+ :type id: int
2740
+ :param name: New Image name.
2741
+ :type name: str
2742
+ :return: Information about updated Image.
2743
+ :rtype: :class:`ImageInfo`
2744
+ :Usage example:
2745
+
2746
+ .. code-block:: python
2747
+
2748
+ import supervisely as sly
2749
+
2750
+ os.environ['SERVER_ADDRESS'] = 'https://app.supervisely.com'
2751
+ os.environ['API_TOKEN'] = 'Your Supervisely API Token'
2752
+ api = sly.Api.from_env()
2753
+
2754
+ image_id = 376729
2755
+ new_image_name = 'new_image_name.jpg'
2756
+ img_info = api.image.rename(image_id, new_image_name)
2757
+ """
2758
+ return self.edit(id=id, name=name)
2676
2759
 
2677
2760
  def add_tag(self, image_id: int, tag_id: int, value: Optional[Union[str, int]] = None) -> None:
2678
2761
  """
@@ -192,9 +192,10 @@ class ImageConverter(BaseConverter):
192
192
  mimetypes.add_type("image/heif", ".heif") # to extend types_map
193
193
  mimetypes.add_type("image/jpeg", ".jfif") # to extend types_map
194
194
  mimetypes.add_type("image/avif", ".avif") # to extend types_map
195
+ mimetypes.add_type("image/bmp", ".bmp") # to extend types_map
195
196
 
196
- mime = magic.Magic(mime=True)
197
- mimetype = mime.from_file(path)
197
+ with open(path, "rb") as f:
198
+ mimetype = magic.from_buffer(f.read(), mime=True)
198
199
  file_ext = mimetypes.guess_extension(mimetype)
199
200
  if file_ext is None:
200
201
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supervisely
3
- Version: 6.73.216
3
+ Version: 6.73.218
4
4
  Summary: Supervisely Python SDK.
5
5
  Home-page: https://github.com/supervisely/supervisely
6
6
  Author: Supervisely
@@ -28,7 +28,7 @@ supervisely/api/dataset_api.py,sha256=7iwAyz3pmzFG2i072gLdXjczfBGbyj-V_rRl7Tx-V3
28
28
  supervisely/api/file_api.py,sha256=y8FkE-vx1382cbhNo_rTZs7SobrkxmYQAe79CpvStO4,54279
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=TALfxJoBf6xYJs_UKuX7nNt6WNADsAHso2r8cffSm3o,135794
31
+ supervisely/api/image_api.py,sha256=wnzoCbD5vV8f8joBQsNCbRjoG0jhyAXHe1ZM8YhbCsc,138727
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
@@ -557,7 +557,7 @@ supervisely/convert/__init__.py,sha256=gRTV93OYJPI3FNfy78HO2SfR59qQ3FFKFSy_jw1ad
557
557
  supervisely/convert/base_converter.py,sha256=F5oCwQZ_w7XlIIQnW-y-2scvA9sC8vCJL2XMP3DtPZg,14343
558
558
  supervisely/convert/converter.py,sha256=0F93xZmyprua63C6KxIeh0AbaFab81LiWqlkOVrkaYU,8672
559
559
  supervisely/convert/image/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
560
- supervisely/convert/image/image_converter.py,sha256=Er-QX6qyVO4p72iJ3ae0YMF9gSfm_SUimoH6id0MIIs,9446
560
+ supervisely/convert/image/image_converter.py,sha256=6GC8-erDTIJnjkcDvaxs8VAItBNsJrMHaZtOcOsphew,9537
561
561
  supervisely/convert/image/image_helper.py,sha256=RkBAyxxXmDG1Z5WFuO9kBDK8MN1Kl7Z25DX9-CwZ7OI,3647
562
562
  supervisely/convert/image/cityscapes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
563
563
  supervisely/convert/image/cityscapes/cityscapes_converter.py,sha256=msmsR2W-Xiod06dwn-MzmkbrEmQQqlKh7zyfTrW6YQw,7854
@@ -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.216.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1001
- supervisely-6.73.216.dist-info/METADATA,sha256=Bn5oSKjMCU1TstxJBPv0-scrrsm8UqzZ7itIe9YH-QY,33090
1002
- supervisely-6.73.216.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
1003
- supervisely-6.73.216.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1004
- supervisely-6.73.216.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1005
- supervisely-6.73.216.dist-info/RECORD,,
1000
+ supervisely-6.73.218.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1001
+ supervisely-6.73.218.dist-info/METADATA,sha256=EnGwT_zAqgvOytZQYfG8Cc6sTL3MniXkWeNgG-TXZP4,33090
1002
+ supervisely-6.73.218.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
1003
+ supervisely-6.73.218.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1004
+ supervisely-6.73.218.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1005
+ supervisely-6.73.218.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (75.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5