unitlab 2.1.1__tar.gz → 2.1.3__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unitlab
3
- Version: 2.1.1
3
+ Version: 2.1.3
4
4
  Home-page: https://github.com/teamunitlab/unitlab-sdk
5
5
  Author: Unitlab Inc.
6
6
  Author-email: team@unitlab.ai
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
2
2
 
3
3
  setup(
4
4
  name="unitlab",
5
- version="2.1.1",
5
+ version="2.1.3",
6
6
  license="MIT",
7
7
  author="Unitlab Inc.",
8
8
  author_email="team@unitlab.ai",
@@ -93,7 +93,7 @@ class UnitlabClient:
93
93
  self.close()
94
94
 
95
95
  def _get_headers(self):
96
- return {"Authorization": f"Api-Key {self.api_key}"} if self.api_key else None
96
+ return {"Authorization": f"Api-Key {self.api_key}"}
97
97
 
98
98
  @utils.handle_exceptions
99
99
  def _get(self, endpoint):
@@ -102,10 +102,10 @@ class UnitlabClient:
102
102
  )
103
103
 
104
104
  @utils.handle_exceptions
105
- def _post(self, endpoint, data):
105
+ def _post(self, endpoint, data=None):
106
106
  return self.api_session.post(
107
107
  urllib.parse.urljoin(self.api_url, endpoint),
108
- json=data,
108
+ json=data or {},
109
109
  headers=self._get_headers(),
110
110
  )
111
111
 
@@ -259,6 +259,9 @@ class UnitlabClient:
259
259
  )
260
260
  return response["pk"]
261
261
 
262
+ def finalize_dataset(self, dataset_id):
263
+ return self._post(f"/api/sdk/datasets/{dataset_id}/finalize/")
264
+
262
265
  def dataset_upload(
263
266
  self,
264
267
  name,
@@ -302,4 +305,4 @@ class UnitlabClient:
302
305
  raise e
303
306
 
304
307
  asyncio.run(main())
305
- self.dataset_download(dataset_id, "COCO")
308
+ self.finalize_dataset(dataset_id)
@@ -39,18 +39,6 @@ class COCO:
39
39
  self.data_path
40
40
  )
41
41
  )
42
- if self.annotation_type not in [
43
- "img_bbox",
44
- "img_semantic_segmentation",
45
- "img_instance_segmentation",
46
- "img_polygon",
47
- "img_keypoints",
48
- ]:
49
- raise ValueError(
50
- "Invalid annotation type '{}'. Supported types are: ['img_bbox', 'img_semantic_segmentation', 'img_polygon', 'img_keypoints']".format(
51
- self.annotation_type
52
- )
53
- )
54
42
  for required_key in ["images", "annotations", "categories"]:
55
43
  if required_key not in self.dataset.keys():
56
44
  raise KeyError(
@@ -284,30 +272,16 @@ class DatasetUploadHandler(COCO):
284
272
  )
285
273
 
286
274
  def get_img_instance_segmentation_payload(self, anns):
287
- predicted_classes = set()
288
- annotations = []
289
- for ann in anns:
290
- annotations.append(
291
- {
292
- "segmentation": ann["segmentation"],
293
- "category_id": self.original_category_referecences.get(
294
- ann["category_id"]
295
- ),
296
- }
297
- )
298
- predicted_classes.add(
299
- self.original_category_referecences.get(ann["category_id"])
300
- )
301
- return json.dumps(
302
- {
303
- "annotations": annotations,
304
- "predicted_classes": list(predicted_classes),
305
- "classes": self.classes,
306
- }
307
- )
275
+ return self.get_img_semantic_segmentation_payload(anns)
308
276
 
309
277
  def get_img_polygon_payload(self, anns):
310
- logger.warning("Not implemented yet")
278
+ return self.get_img_semantic_segmentation_payload(anns)
279
+
280
+ def get_img_line_payload(self, anns):
281
+ return self.get_img_semantic_segmentation_payload(anns)
282
+
283
+ def get_img_point_payload(self, anns):
284
+ return self.get_img_semantic_segmentation_payload(anns)
311
285
 
312
286
  def get_img_skeleton_payload(self, anns):
313
287
  logger.warning("Not implemented yet")
@@ -32,9 +32,11 @@ class DownloadType(str, Enum):
32
32
 
33
33
  class AnnotationType(str, Enum):
34
34
  IMG_BBOX = "img_bbox"
35
- IMG_POLYGON = "img_polygon"
36
35
  IMG_SEMANTIC_SEGMENTATION = "img_semantic_segmentation"
37
36
  IMG_INSTANCE_SEGMENTATION = "img_instance_segmentation"
37
+ IMG_POLYGON = "img_polygon"
38
+ IMG_LINE = "img_line"
39
+ IMG_POINT = "img_point"
38
40
  IMG_SKELETON = "img_skeleton"
39
41
 
40
42
 
@@ -104,10 +106,7 @@ def dataset_upload(
104
106
  help_prompt = ", ".join(
105
107
  f"{idx}: {license['name']}" for idx, license in enumerate(licenses)
106
108
  )
107
- chosen_license = typer.prompt(
108
- f"Select license {help_prompt}",
109
- type=LicenseEnum,
110
- )
109
+ chosen_license = typer.prompt(f"Select license {help_prompt}", type=LicenseEnum)
111
110
  client.dataset_upload(
112
111
  name,
113
112
  annotation_type.value,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unitlab
3
- Version: 2.1.1
3
+ Version: 2.1.3
4
4
  Home-page: https://github.com/teamunitlab/unitlab-sdk
5
5
  Author: Unitlab Inc.
6
6
  Author-email: team@unitlab.ai
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes