mmdetection3d icon indicating copy to clipboard operation
mmdetection3d copied to clipboard

[Bug] Variable referenced before assignment / typo?

Open chbehrens opened this issue 1 year ago • 1 comments

Prerequisite

Task

I'm using the official example scripts/configs for the officially supported tasks/models/datasets.

Branch

main branch https://github.com/open-mmlab/mmdetection3d

Environment

Doesn't depend on the environment, plain local bug in the code.

Reproduces the problem - code sample

This is the affected code where pts_semantic_mask is used without being assigned https://github.com/open-mmlab/mmdetection3d/blob/fe25f7a51d36e3702f961e198894580d83c4387b/mmdet3d/datasets/transforms/loading.py#L1006

Reproduces the problem - command or script

Reproduces the problem - error message

Additional information

There is a bug in the _load_panoptic_3d function of LoadAnnotations3D that was introduced in https://github.com/open-mmlab/mmdetection3d/pull/2223. Potentially, the line https://github.com/open-mmlab/mmdetection3d/blob/fe25f7a51d36e3702f961e198894580d83c4387b/mmdet3d/datasets/transforms/loading.py#L1006 should just read elif self.dataset_type == 'nuscenes': pts_semantic_mask = pts_panoptic_mask // self.seg_offset as currently pts_semantic_mask is referenced before it is assigned in the nuscenes case. In addition, it will fail if neither nuscenes nor semantickitti is given as dataset type because then pts_semantic_mask is unassigned here https://github.com/open-mmlab/mmdetection3d/blob/fe25f7a51d36e3702f961e198894580d83c4387b/mmdet3d/datasets/transforms/loading.py#L1008 and here https://github.com/open-mmlab/mmdetection3d/blob/fe25f7a51d36e3702f961e198894580d83c4387b/mmdet3d/datasets/transforms/loading.py#L1016 As I can't test it at the moment I'm just opening an issue to document it, maybe @xizaoqu can quickly check it as author of the function?

chbehrens avatar Jan 09 '24 13:01 chbehrens

Thanks for your feedback. The Nuscenes dataset was not supported when I implemented this code. Thus I will remove this "elif" for now. Feel free to add the PR if you are interested.

xizaoqu avatar Jan 10 '24 02:01 xizaoqu