Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Mar 31, 2023 · 7 comments

Comments

@cskate1997
Copy link

(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-><city_name>->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
Copy link

have you able to solve it ?

@cskate1997
Copy link
Author

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
Copy link

excuse me,have you able to solve it ?

@yanganlan0310
Copy link

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
Copy link

00ffcc commented Aug 15, 2023

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
Copy link

Cai-RS commented Jan 6, 2024

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
Copy link

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吧?这种情况有办法解决吗?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants