open-mmlab / mmdetection3d

OpenMMLab's next-generation platform for general 3D object detection.
https://mmdetection3d.readthedocs.io/en/latest/
Apache License 2.0
5.34k stars 1.55k forks source link

[Bug] Fail to visualize nuScenes dataset with browse_dataset.py #2749

Open ZitengXue opened 1 year ago

ZitengXue commented 1 year ago

Prerequisite

Task

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

Branch

1.x branch https://github.com/open-mmlab/mmdetection3d/tree/dev-1.x

Environment

mmcv==2.0.0rc4 mmdet==3.0.0rc5 mmdet3d==1.1.0 (I also tried 1.1.1 still this error) mmengine==0.8.4 torch==1.9.0+cu111 torchvision==0.10.0+cu111

Reproduces the problem - code sample

The 137 line of browse_dataset.py

Reproduces the problem - command or script

python tools/misc/browse_dataset.py configs/base/datasets/nus-mono3d.py --task mono_det --output-dir /media/xzt/disk/output

Reproduces the problem - error message

First I run the command it crush with this error:

python tools/misc/browse_dataset.py configs/base/datasets/nus-mono3d.py --task mono_det --output-dir ./output 09/25 13:17:10 - mmengine - INFO - ------------------------------ 09/25 13:17:10 - mmengine - INFO - The length of the dataset: 168780 09/25 13:17:10 - mmengine - INFO - The number of instances per category in the dataset: +----------------------+--------+ | category | number | +----------------------+--------+ | car | 517166 | | truck | 93259 | | trailer | 28466 | | bus | 16671 | | construction_vehicle | 15882 | | bicycle | 11154 | | motorcycle | 11777 | | pedestrian | 213239 | | traffic_cone | 91774 | | barrier | 150210 | +----------------------+--------+ /home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/visualization/visualizer.py:196: UserWarning: Failed to add <class 'mmengine.visualization.vis_backend.LocalVisBackend'>, please provide the save_dir argument. warnings.warn(f'Failed to add {vis_backend.class}, ' [ ] 1/168780, 0.2 task/s, elapsed: 4s, ETA: 719244sTraceback (most recent call last): File "tools/misc/browse_dataset.py", line 152, in main() File "tools/misc/browse_dataset.py", line 123, in main for i, item in enumerate(dataset): File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py", line 409, in getitem data = self.prepare_data(idx) File "/home/xzt/Downloads/mmdetection3d-1.1.0/mmdet3d/datasets/det3d_dataset.py", line 387, in prepare_data example = self.pipeline(input_dict) File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py", line 58, in call data = t(data) File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmcv/transforms/base.py", line 12, in call return self.transform(results) File "/home/xzt/Downloads/mmdetection3d-1.1.0/mmdet3d/datasets/transforms/formating.py", line 119, in transform return self.pack_single_results(results) File "/home/xzt/Downloads/mmdetection3d-1.1.0/mmdet3d/datasets/transforms/formating.py", line 210, in pack_single_results gt_instances_3d[self._remove_prefix(key)] = results[key] File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/structures/instance_data.py", line 151, in setattr if len(self) > 0: File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/structures/instance_data.py", line 306, in len return len(self.values()[0]) File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/torch/_tensor.py", line 589, in len raise TypeError("len() of a 0-d tensor") TypeError: len() of a 0-d tensor

I thought the reason for this is that lack of the args of save_dir, so I add this in #### mmengine/visualization/visualizer.py:196

After this, I run the command repeatly still got error, which looks like:


File "tools/misc/browse_dataset.py", line 152, in main() File "tools/misc/browse_dataset.py", line 123, in main for i, item in enumerate(dataset): File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py", line 409, in getitem data = self.prepare_data(idx) File "/home/xzt/Downloads/mmdetection3d-1.1.0/mmdet3d/datasets/det3d_dataset.py", line 387, in prepare_data example = self.pipeline(input_dict) File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py", line 58, in call data = t(data) File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmcv/transforms/base.py", line 12, in call return self.transform(results) File "/home/xzt/Downloads/mmdetection3d-1.1.0/mmdet3d/datasets/transforms/formating.py", line 119, in transform return self.pack_single_results(results) File "/home/xzt/Downloads/mmdetection3d-1.1.0/mmdet3d/datasets/transforms/formating.py", line 210, in pack_single_results gt_instances_3d[self._remove_prefix(key)] = results[key] File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/structures/instance_data.py", line 151, in setattr if len(self) > 0: File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/mmengine/structures/instance_data.py", line 306, in len return len(self.values()[0]) File "/home/xzt/miniconda3/envs/detr/lib/python3.8/site-packages/torch/_tensor.py", line 589, in len raise TypeError("len() of a 0-d tensor") TypeError: len() of a 0-d tensor


Additional information

It looks like the second image didn't load successfully, only one image was generated. The training process can runs successfully 我尝试使用官方文档给的可视化数据集命令可视化nuScenes数据集,但是只有一张图片可视化成功了,第二张图片无法正常读取

ZitengXue commented 1 year ago

I also tried the latest version still got this error,but the training process goes well

dudqls1994 commented 1 month ago

@ZitengXue Have you solved this issue? If you solved it, can you tell me how?