zenseact / zod

Software Development Kit for the Zenseact Open Dataset (ZOD)
https://zod.zenseact.com
MIT License
92 stars 13 forks source link

ValueError: 'RoadEdge_RaisedCurb' is not a valid EgoRoadClass #47

Open SyedShafiq opened 2 months ago

SyedShafiq commented 2 months ago

Hello,

I am encountering the following error: ValueError: 'RoadEdge_RaisedCurb' is not a valid EgoRoadClass

This is error is generated when I am running the following piece of code in devkit_tutorial.

from zod.utils.polygon_transformations import polygons_to_binary_mask

zod_frame = zod_frames[9158]

#get the ego road annotations
polygon_annotations = zod_frame.get_annotation(AnnotationProject.EGO_ROAD)
# convert the polygons to a binary mask (which can be used
# for ground truth in e.g. semantic segmentation)
mask = polygons_to_binary_mask(polygon_annotations)

# visualize the mask
plt.axis("off")
plt.imshow(mask)
plt.show()

Could you please suggest a workaround so that I can see the segmentation on the image? Seems like there are more than 2 classes in the EgoAnnotation data.

atonderski commented 2 months ago

Very sorry for your issues. parsing was indeed broken for ego road (for a subset of frames at least). This PR should fix it.

SyedShafiq commented 2 months ago

Thank you for your quick response. When can I expect it to be merged with the main branch?

wljungbergh commented 2 months ago

This PR is now merged. If you are using the source code you can simply take down the latest changes! If you are using the pypi package, that will be updated later this week!

ollema commented 2 months ago

hi @SyedShafiq! could you please confirm if the PR resolved your issues so we could close this issue? thanks!

SyedShafiq commented 2 months ago

This is the error, encountered.

Exception has occurred: TypeError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
'EgoRoadAnnotation' object is not iterable
  File "D:\Thesis_Shafiq\Scene_Risk\Code\zodRepo\zod\utils\polygon_transformations.py", line 38, in polygons_to_binary_mask
    for polygon in multi_polygon:
  File "D:\Thesis_Shafiq\Scene_Risk\Code\zodRepo\examples\devkit_tutorialPy.py", line 322, in <module>
    mask = polygons_to_binary_mask(polygon_annotations)
  File "C:\Users\I010392\AppData\Local\Programs\Python\Python310\Lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\I010392\AppData\Local\Programs\Python\Python310\Lib\runpy.py", line 196, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
TypeError: 'EgoRoadAnnotation' object is not iterable``

Upon debugging, there seems to be an error in this piece of code from polygin_transformations.py file:

def polygons_to_binary_mask(multi_polygons, img_shape=(2168, 3848)):
    """
    Create binary mask for list of multi-polygons
    """
    assert len(img_shape) == 2

    mask = _create_image_mask(img_shape)
    for multi_polygon in multi_polygons:
        for polygon in multi_polygon:
            mask += polygon_to_mask(polygon, img_shape, 1)
    return mask.astype(bool)
atonderski commented 2 months ago

You are right, the notebook still had issues with ego road annotations. Should be fixed here (also added another test to check for errors in the tutorial) https://github.com/zenseact/zod/commit/54c698d4e22c78013c522dc8e6d4409e1bf10f0f

Can you install/pull from latest master and try again? Sorry about the hassle