Hello, I was using COCOConverter to get annotation and keep getting the same error.
The error message seems like one of the annotations doesn’t have the right bbox
value inside.
Is there any way to figure out which one has the issue?
cuz in my project, every data row looks well-annotated and it is almost impossible to figure out the wrong one.
!pip3 install labelbox[data]
from labelbox.data.annotation_types import Label, LabelList, ImageData, Point, ObjectAnnotation, Rectangle, Polygon
from labelbox.data.serialization import COCOConverter
from labelbox import Client
from google.colab import drive
drive.mount('/content/Google')
import json
import shutil
import os
LB_API_KEY = ""
client = Client(api_key=LB_API_KEY)
project = client.get_project('')
labels = project.label_generator()
image_path = './images/'
coco_labels = COCOConverter.serialize_instances(
labels,
image_root=image_path,
ignore_existing_data=True)
/usr/local/lib/python3.7/dist-packages/labelbox/data/annotation_types/classification/classification.py:85: UserWarning: Dropdown classification is deprecated and will be removed in a future release
warnings.warn("Dropdown classification is deprecated and will be "
35it [00:24, 2.05it/s]/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py:37: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
np.array(s.exterior.coords).ravel().tolist() for s in shapely
42it [00:27, 2.24it/s]/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py:37: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
np.array(s.exterior.coords).ravel().tolist() for s in shapely
55it [00:34, 1.83it/s]/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py:37: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
np.array(s.exterior.coords).ravel().tolist() for s in shapely
65it [00:44, 1.01it/s]/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py:37: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
np.array(s.exterior.coords).ravel().tolist() for s in shapely
69it [00:46, 1.46it/s]/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py:37: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
np.array(s.exterior.coords).ravel().tolist() for s in shapely
71it [00:49, 1.05s/it]/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py:37: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
np.array(s.exterior.coords).ravel().tolist() for s in shapely
112it [01:20, 1.48it/s]/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py:37: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
np.array(s.exterior.coords).ravel().tolist() for s in shapely
136it [01:36, 4.87it/s]/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py:37: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
np.array(s.exterior.coords).ravel().tolist() for s in shapely
464it [04:24, 2.55it/s]
---------------------------------------------------------------------------
_RemoteTraceback Traceback (most recent call last)
_RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/lib/python3.7/concurrent/futures/process.py", line 239, in _process_worker
r = call_item.fn(*call_item.args, **call_item.kwargs)
File "/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py", line 113, in process_label
categories[annotation.name]))
File "/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py", line 26, in mask_to_coco_object_annotation
xmin, ymin, xmax, ymax = shapely.bounds
ValueError: not enough values to unpack (expected 4, got 0)
"""
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
<ipython-input-6-cb6f848644e4> in <module>()
6 labels,
7 image_root=image_path,
----> 8 ignore_existing_data=True)
4 frames
/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/converter.py in serialize_instances(labels, image_root, ignore_existing_data, max_workers)
59 return CocoInstanceDataset.from_common(labels=labels,
60 image_root=image_root,
---> 61 max_workers=max_workers).dict()
62
63 @staticmethod
/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py in from_common(cls, labels, image_root, max_workers)
145 ]
146 results = [
--> 147 future.result() for future in tqdm(as_completed(futures))
148 ]
149 else:
/usr/local/lib/python3.7/dist-packages/labelbox/data/serialization/coco/instance_dataset.py in <listcomp>(.0)
145 ]
146 results = [
--> 147 future.result() for future in tqdm(as_completed(futures))
148 ]
149 else:
/usr/lib/python3.7/concurrent/futures/_base.py in result(self, timeout)
426 raise CancelledError()
427 elif self._state == FINISHED:
--> 428 return self.__get_result()
429
430 self._condition.wait(timeout)
/usr/lib/python3.7/concurrent/futures/_base.py in __get_result(self)
382 def __get_result(self):
383 if self._exception:
--> 384 raise self._exception
385 else:
386 return self._result
ValueError: not enough values to unpack (expected 4, got 0)