waspinator / pycococreator

Helper functions to create COCO datasets
Apache License 2.0
765 stars 179 forks source link

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part. #47

Open cskate1997 opened 1 year ago

cskate1997 commented 1 year ago

(venv) root@cc3180440f4b:/opendr/src/opendr/perception/panoptic_segmentation/efficient_ps/algorithm/EfficientPS# python tools/convert_cityscapes.py ./data_2/ ./data/cityscapes/ Loading Cityscapes from ./data_2/ Converting train ... 0%| | 0/2975 [00:00<?, ?it/s] multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, *kwds)) File "/usr/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar return list(map(args)) File "tools/convert_cityscapes.py", line 163, in call coco_ann_i = pct.create_annotation_info( File "/opendr/venv/lib/python3.8/site-packages/pycococreatortools/pycococreatortools.py", line 99, in create_annotation_info segmentation = binary_mask_to_polygon(binary_mask, tolerance) File "/opendr/venv/lib/python3.8/site-packages/pycococreatortools/pycococreatortools.py", line 48, in binary_mask_to_polygon contours = np.subtract(contours, 1) ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

I am trying to convert my Citscapes dataset to COCO style using pycococreator with following subfolder.

  1. gtFine
  2. leftImg8bit

Inside gtFine->train->->following items 1.aachen_000057_000019_gtFine_color.png aachen_000057_000019_gtFine_instanceIds.png aachen_000057_000019_gtFine_labelIds.png
aachen_000057_000019_gtFine_polygons.json

How can I solve the above ValueError issue?

Abdullah955 commented 1 year ago

have you able to solve it ?

cskate1997 commented 1 year ago

have you able to solve it ?

No, I don’t where problem is with I even tried to change numpy versions, but didn’t worked. By changing another version of numpy didn’t get above error but got another error.

yy1443221758 commented 1 year ago

excuse me,have you able to solve it ?

yanganlan0310 commented 1 year ago

I also encountered this problem,this error becourse this line code:

contours = np.subtract(contours, 1)

The previous line of code for this got a list object and this list's length >1,it's original length should have been 1,so,you should keep only one of these elements

00ffcc commented 10 months ago

also encountered this problem maybe there are more than one polygons?


yes, measure.find_contours() returns more than one mask. you can solve the peoblem by simply using the biggest mask.

contours = measure.find_contours(padded_binary_mask, 0.5)
contours=sorted(contours,key=lambda x: len(x),reverse=True)[0:1]#可能返回多个mask
contours = np.subtract(contours, 1)
Cai-RS commented 5 months ago

also encountered this problem maybe there are more than one polygons?

yes, measure.find_contours() returns more than one mask. you can solve the peoblem by simply using the biggest mask.

contours = measure.find_contours(padded_binary_mask, 0.5)
contours=sorted(contours,key=lambda x: len(x),reverse=True)[0:1]#可能返回多个mask
contours = np.subtract(contours, 1)

可是如果一个物体被遮挡成不相连的两部分,应该是要保留这两部分的mask吧?这种情况有办法解决吗?

wetrytoease commented 2 months ago

also encountered this problem maybe there are more than one polygons? yes, measure.find_contours() returns more than one mask. you can solve the peoblem by simply using the biggest mask.

contours = measure.find_contours(padded_binary_mask, 0.5)
contours=sorted(contours,key=lambda x: len(x),reverse=True)[0:1]#可能返回多个mask
contours = np.subtract(contours, 1)

可是如果一个物体被遮挡成不相连的两部分,应该是要保留这两部分的mask吧?这种情况有办法解决吗?

我也是这个问题,求助大佬解决了吗???

miquel-espinosa commented 1 week ago

@waspinator this is still a problem

miquel-espinosa commented 1 week ago

51 This edit should fix it.