open-mmlab / mmdetection3d

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

[Bug] Det3DLocalVisualizer 对象的 show 方法中,该对象缺少一个名为 view_control 的属性 #2857

Open zyu opened 6 months ago

zyu commented 6 months ago

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

File "demo/pcd_demo.py", line 90, in main() File "demo/pcd_demo.py", line 80, in main inferencer(call_args) File "e:\mm\mmdetection3d\mmdet3d\apis\inferencers\base_3d_inferencer.py", line 213, in call visualization = self.visualize(ori_inputs, preds, File "e:\mm\mmdetection3d\mmdet3d\apis\inferencers\lidar_det3d_inferencer.py", line 190, in visualize self.visualizer.add_datasample( File "C:\ProgramData\miniconda3\envs\openmmlab\lib\site-packages\mmengine\dist\utils.py", line 418, in wrapper return func(*args, *kwargs) File "e:\mm\mmdetection3d\mmdet3d\visualization\local_visualizer.py", line 1082, in add_datasample self.show( File "C:\ProgramData\miniconda3\envs\openmmlab\lib\site-packages\mmengine\dist\utils.py", line 418, in wrapper return func(args, kwargs) File "e:\mm\mmdetection3d\mmdet3d\visualization\local_visualizer.py", line 868, in show self.view_control.convert_to_pinhole_camera_parameters() # noqa: E501 AttributeError: 'Det3DLocalVisualizer' object has no attribute 'view_control'

Reproduces the problem - code sample

python demo/pcd_demo.py demo/data/kitti/000008.bin pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth --show

Reproduces the problem - command or script

python demo/pcd_demo.py demo/data/kitti/000008.bin pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth --show

Reproduces the problem - error message

python demo/pcd_demo.py demo/data/kitti/000008.bin pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth --show

Additional information

python demo/pcd_demo.py demo/data/kitti/000008.bin pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth --show

sunjiahao1999 commented 6 months ago

What version of system are you using, Windows/Linux ? And check the version of open3d in your environment.

RedHeartSecretMan commented 5 months ago

I encountered the same problem in the officially provided docker environment.

mmdet3d.__version__ 
1.4.0
open3d.__version__ 
0.17.0

run script mmdetection3d/demo/inference_demo.ipynb as:

# inference and visualize
# NOTE: use the `Esc` key to exit Open3D window in Jupyter Notebook Environment
inferencer(inputs, show=True)

then raise error as:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[/tmp/ipykernel_17325/1388200773.py](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a22544c4b4a332e33362e39303135227d.vscode-resource.vscode-cdn.net/tmp/ipykernel_17325/1388200773.py) in <module>
      1 # inference and visualize
      2 # NOTE: use the `Esc` key to exit Open3D window in Jupyter Notebook Environment
----> 3 inferencer(inputs, show=True)

[/mmdetection3d/mmdet3d/apis/inferencers/base_3d_inferencer.py](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a22544c4b4a332e33362e39303135227d.vscode-resource.vscode-cdn.net/mmdetection3d/mmdet3d/apis/inferencers/base_3d_inferencer.py) in __call__(self, inputs, batch_size, return_datasamples, **kwargs)
    212             preds.extend(self.forward(data, **forward_kwargs))
    213             visualization = self.visualize(ori_inputs, preds,
--> 214                                            **visualize_kwargs)
    215             results = self.postprocess(preds, visualization,
    216                                        return_datasamples,

[/mmdetection3d/mmdet3d/apis/inferencers/lidar_det3d_inferencer.py](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a22544c4b4a332e33362e39303135227d.vscode-resource.vscode-cdn.net/mmdetection3d/mmdet3d/apis/inferencers/lidar_det3d_inferencer.py) in visualize(self, inputs, preds, return_vis, show, wait_time, draw_pred, pred_score_thr, no_save_vis, img_out_dir)
    198                 pred_score_thr=pred_score_thr,
    199                 o3d_save_path=o3d_save_path,
--> 200                 vis_task='lidar_det',
    201             )
    202             results.append(points)

[/opt/conda/lib/python3.7/site-packages/mmengine/dist/utils.py](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a22544c4b4a332e33362e39303135227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.7/site-packages/mmengine/dist/utils.py) in wrapper(*args, **kwargs)
    416     def wrapper(*args, **kwargs):
    417         if is_main_process():
--> 418             return func(*args, **kwargs)
...
--> 868                 self.view_control.convert_to_pinhole_camera_parameters()  # noqa: E501
    869             if wait_time != -1:
    870                 self.last_time = time.time()

AttributeError: 'Det3DLocalVisualizer' object has no attribute 'view_control'

Can't seem to visualize?

zbaishancha commented 5 months ago

I encountered the same problem in the officially provided docker environment.

mmdet3d.__version__ 
1.4.0
open3d.__version__ 
0.17.0

run script mmdetection3d/demo/inference_demo.ipynb as:

# inference and visualize
# NOTE: use the `Esc` key to exit Open3D window in Jupyter Notebook Environment
inferencer(inputs, show=True)

then raise error as:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[/tmp/ipykernel_17325/1388200773.py](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a22544c4b4a332e33362e39303135227d.vscode-resource.vscode-cdn.net/tmp/ipykernel_17325/1388200773.py) in <module>
      1 # inference and visualize
      2 # NOTE: use the `Esc` key to exit Open3D window in Jupyter Notebook Environment
----> 3 inferencer(inputs, show=True)

[/mmdetection3d/mmdet3d/apis/inferencers/base_3d_inferencer.py](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a22544c4b4a332e33362e39303135227d.vscode-resource.vscode-cdn.net/mmdetection3d/mmdet3d/apis/inferencers/base_3d_inferencer.py) in __call__(self, inputs, batch_size, return_datasamples, **kwargs)
    212             preds.extend(self.forward(data, **forward_kwargs))
    213             visualization = self.visualize(ori_inputs, preds,
--> 214                                            **visualize_kwargs)
    215             results = self.postprocess(preds, visualization,
    216                                        return_datasamples,

[/mmdetection3d/mmdet3d/apis/inferencers/lidar_det3d_inferencer.py](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a22544c4b4a332e33362e39303135227d.vscode-resource.vscode-cdn.net/mmdetection3d/mmdet3d/apis/inferencers/lidar_det3d_inferencer.py) in visualize(self, inputs, preds, return_vis, show, wait_time, draw_pred, pred_score_thr, no_save_vis, img_out_dir)
    198                 pred_score_thr=pred_score_thr,
    199                 o3d_save_path=o3d_save_path,
--> 200                 vis_task='lidar_det',
    201             )
    202             results.append(points)

[/opt/conda/lib/python3.7/site-packages/mmengine/dist/utils.py](https://vscode-remote+ssh-002dremote-002b7b22686f73744e616d65223a22544c4b4a332e33362e39303135227d.vscode-resource.vscode-cdn.net/opt/conda/lib/python3.7/site-packages/mmengine/dist/utils.py) in wrapper(*args, **kwargs)
    416     def wrapper(*args, **kwargs):
    417         if is_main_process():
--> 418             return func(*args, **kwargs)
...
--> 868                 self.view_control.convert_to_pinhole_camera_parameters()  # noqa: E501
    869             if wait_time != -1:
    870                 self.last_time = time.time()

AttributeError: 'Det3DLocalVisualizer' object has no attribute 'view_control'

Can't seem to visualize?

If you are executing the project in a python environment on a remote server, then the problem is caused by the lack of a monitor on your server.

hitbuyi commented 3 months ago

I have the same problem in Windows 11, add

import os
os.environ['DISPLAY'] = '1'

to solve it

861482002 commented 2 months ago
  loc :\mmdet3d\visualization\local_visualizer.py
    if os.environ.get('DISPLAY', None) is not None and show:
        o3d_vis.create_window()
        self.view_control = o3d_vis.get_view_control()
    return o3d_vis

我也遇到了这个问题,是因为这段代码,会判断你的环境变量中有没有'DISPLAY',添加环境变量就行了 import os os.environ['DISPLAY'] = '1',或者任何其他的字符串都行 就能解决