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

[Bug] bevfusion multi_modality_demo.py运行报错 #3056

Open
3 tasks done
limllzu opened this issue Nov 16, 2024 · 0 comments
Open
3 tasks done

[Bug] bevfusion multi_modality_demo.py运行报错 #3056

limllzu opened this issue Nov 16, 2024 · 0 comments

Comments

@limllzu
Copy link

limllzu commented Nov 16, 2024

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

使用官方文档提供的方法进行安装mmdetection3d
然后使用python projects/BEVFusion/setup.py develop安装bevfusion

Reproduces the problem - code sample

Copyright (c) OpenMMLab. All rights reserved.

from argparse import ArgumentParser

import mmcv

from mmdet3d.apis import inference_multi_modality_detector, init_model
from mmdet3d.registry import VISUALIZERS

def parse_args():
parser = ArgumentParser()
parser.add_argument('pcd', help='Point cloud file')
parser.add_argument('img', help='image file')
parser.add_argument('ann', help='ann file')
parser.add_argument('config', help='Config file')
parser.add_argument('checkpoint', help='Checkpoint file')
parser.add_argument(
'--device', default='cuda:0', help='Device used for inference')
parser.add_argument(
'--cam-type',
type=str,
default='CAM_FRONT',
help='choose camera type to inference')
parser.add_argument(
'--score-thr', type=float, default=0.0, help='bbox score threshold')
parser.add_argument(
'--out-dir', type=str, default='demo', help='dir to save results')
parser.add_argument(
'--show',
action='store_true',
help='show online visualization results')
parser.add_argument(
'--snapshot',
action='store_true',
help='whether to save online visualization results')
args = parser.parse_args()
return args

def main(args):
# build the model from a config file and a checkpoint file
model = init_model(args.config, args.checkpoint, device=args.device)

# init visualizer
visualizer = VISUALIZERS.build(model.cfg.visualizer)
visualizer.dataset_meta = model.dataset_meta

# test a single image and point cloud sample
result, data = inference_multi_modality_detector(model, args.pcd, args.img,
                                                 args.ann, args.cam_type)
points = data['inputs']['points']
if isinstance(result.img_path, list):
    img = []
    for img_path in result.img_path:
        single_img = mmcv.imread(img_path)
        single_img = mmcv.imconvert(single_img, 'bgr', 'rgb')
        img.append(single_img)
else:
    img = mmcv.imread(result.img_path)
    img = mmcv.imconvert(img, 'bgr', 'rgb')
data_input = dict(points=points, img=img)

# show the results
visualizer.add_datasample(
    'result',
    data_input,
    data_sample=result,
    draw_gt=False,
    show=args.show,
    wait_time=-1,
    out_file=args.out_dir,
    pred_score_thr=args.score_thr,
    vis_task='multi-modality_det')

if name == 'main':
args = parse_args()
main(args)

Reproduces the problem - command or script

python projects/BEVFusion/demo/multi_modality_demo.py demo/data/nuscenes/n015-2018-07-24-11-22-45+0800__LIDAR_TOP__1532402927647951.pcd.bin demo/data/nuscenes/ demo/data/nuscenes/n015-2018-07-24-11-22-45+0800.pkl projects/BEVFusion/configs/bevfusion_lidar-cam_voxel0075_second_secfpn_8xb4-cyclic-20e_nus-3d.py projects/BEVFusion/bevfusion_lidar-cam_voxel0075_second_secfpn_8xb4-cyclic-20e_nus-3d-5239b1af.pth --cam-type all --score-thr 0.2 --show

Reproduces the problem - error message

Traceback (most recent call last):
File "/home/liml24/anaconda3/envs/bevfusion/lib/python3.8/site-packages/mmengine/utils/misc.py", line 77, in import_modules_from_strings
imported_tmp = import_module(imp)
File "/home/liml24/anaconda3/envs/bevfusion/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 843, in exec_module
File "", line 219, in _call_with_frames_removed
File "/data/liml24Files/project/mmdetection3d/projects/BEVFusion/bevfusion/init.py", line 1, in
from .bevfusion import BEVFusion
File "/data/liml24Files/project/mmdetection3d/projects/BEVFusion/bevfusion/bevfusion.py", line 16, in
from .ops import Voxelization
File "/data/liml24Files/project/mmdetection3d/projects/BEVFusion/bevfusion/ops/init.py", line 1, in
from .bev_pool import bev_pool
File "/data/liml24Files/project/mmdetection3d/projects/BEVFusion/bevfusion/ops/bev_pool/init.py", line 1, in
from .bev_pool import bev_pool
File "/data/liml24Files/project/mmdetection3d/projects/BEVFusion/bevfusion/ops/bev_pool/bev_pool.py", line 3, in
from . import bev_pool_ext
ImportError: /data/liml24Files/project/mmdetection3d/projects/BEVFusion/bevfusion/ops/bev_pool/bev_pool_ext.cpython-38-x86_64-linux-gnu.so: failed to map segment from shared object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/liml24/anaconda3/envs/bevfusion/lib/python3.8/site-packages/mmengine/config/config.py", line 466, in fromfile
import_modules_from_strings(**cfg_dict['custom_imports'])
File "/home/liml24/anaconda3/envs/bevfusion/lib/python3.8/site-packages/mmengine/utils/misc.py", line 84, in import_modules_from_strings
raise ImportError(f'Failed to import {imp}')
ImportError: Failed to import projects.BEVFusion.bevfusion

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "projects/BEVFusion/demo/multi_modality_demo.py", line 78, in
main(args)
File "projects/BEVFusion/demo/multi_modality_demo.py", line 42, in main
model = init_model(args.config, args.checkpoint, device=args.device)
File "/data/liml24Files/project/mmdetection3d/mmdet3d/apis/inference.py", line 59, in init_model
config = Config.fromfile(config)
File "/home/liml24/anaconda3/envs/bevfusion/lib/python3.8/site-packages/mmengine/config/config.py", line 478, in fromfile
raise ImportError(err_msg) from e
ImportError: Failed to import custom modules from {'imports': ['projects.BEVFusion.bevfusion'], 'allow_failed_imports': False}, the current sys.path is:
/data/liml24Files/project/mmdetection3d/projects/BEVFusion/demo
/home/liml24/anaconda3/envs/bevfusion/lib/python38.zip
/home/liml24/anaconda3/envs/bevfusion/lib/python3.8
/home/liml24/anaconda3/envs/bevfusion/lib/python3.8/lib-dynload
/home/liml24/anaconda3/envs/bevfusion/lib/python3.8/site-packages
/data/liml24Files/project/mmdetection3d
/tmp/tmpyh4xlyfx
You should set PYTHONPATH to make sys.path include the directory which contains your custom module

Additional information

预期结果:成功运行

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

1 participant