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

How to use the pre-trained model? #79

Open
Geralt-of-winterfall opened this issue Jan 28, 2024 · 4 comments
Open

How to use the pre-trained model? #79

Geralt-of-winterfall opened this issue Jan 28, 2024 · 4 comments

Comments

@Geralt-of-winterfall
Copy link

Hello,

I've tried to test pre-trained model with the following commands in README

python tools/test.py configs/imvoxelnet/imvoxelnet_kitti.py \
    work_dirs/imvoxelnet_kitti/latest.pth --show \
    --show-dir work_dirs/imvoxelnet_kitti
#and
bash tools/dist_test.sh configs/imvoxelnet/imvoxelnet_kitti.py \
    work_dirs/imvoxelnet_kitti/latest.pth 8 --eval mAP

and the command in getting_started.md

# single-gpu testing
python tools/test.py ${CONFIG_FILE} ${CHECKPOINT_FILE} [--out ${RESULT_FILE}] [--eval ${EVAL_METRICS}] [--show]

However, they didn't work.Can you provide a example to use the pre-trained model with the input of images?

Thank You.

@filaPro
Copy link
Contributor

filaPro commented Jan 29, 2024

Hi @Geralt-of-winterfall ,

Can you please share the full output log. Otherwise it's hard for me to understand they didn't work.

@Geralt-of-winterfall
Copy link
Author

The commad:

bash tools/dist_test.sh configs/imvoxelnet/imvoxelnet_kitti.py checkpoints/KITTI/20210503_214214.pth 8 --eval mAP

the output:

*****************************************
Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. 
*****************************************
Traceback (most recent call last):
  File "tools/test.py", line 153, in <module>
    main()
  File "tools/test.py", line 132, in main
    model.cuda(),
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 376, in _apply
    param_applied = fn(param)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in <lambda>
    return self._apply(lambda t: t.cuda(device))
RuntimeError: CUDA error: out of memory
Traceback (most recent call last):
  File "tools/test.py", line 153, in <module>
    main()
  File "tools/test.py", line 132, in main
    model.cuda(),
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 376, in _apply
    param_applied = fn(param)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in <lambda>
    return self._apply(lambda t: t.cuda(device))
RuntimeError: CUDA error: out of memory
Traceback (most recent call last):
  File "tools/test.py", line 153, in <module>
    main()
  File "tools/test.py", line 132, in main
    model.cuda(),
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 376, in _apply
    param_applied = fn(param)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in <lambda>
    return self._apply(lambda t: t.cuda(device))
RuntimeError: CUDA error: out of memory
Traceback (most recent call last):
  File "tools/test.py", line 153, in <module>
Traceback (most recent call last):
  File "tools/test.py", line 153, in <module>
    main()
  File "tools/test.py", line 132, in main
    model.cuda(),
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 376, in _apply
    param_applied = fn(param)
Traceback (most recent call last):
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in <lambda>
    return self._apply(lambda t: t.cuda(device))
  File "tools/test.py", line 153, in <module>
RuntimeError: CUDA error: out of memory
    main()
  File "tools/test.py", line 132, in main
    model.cuda(),
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 376, in _apply
    param_applied = fn(param)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in <lambda>
    return self._apply(lambda t: t.cuda(device))
RuntimeError: CUDA error: out of memory
    main()
  File "tools/test.py", line 132, in main
    model.cuda(),
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 376, in _apply
    param_applied = fn(param)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in <lambda>
    return self._apply(lambda t: t.cuda(device))
RuntimeError: CUDA error: out of memory
Traceback (most recent call last):
  File "tools/test.py", line 153, in <module>
    main()
  File "tools/test.py", line 132, in main
    model.cuda(),
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 376, in _apply
    param_applied = fn(param)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in <lambda>
    return self._apply(lambda t: t.cuda(device))
RuntimeError: CUDA error: out of memory
Traceback (most recent call last):
  File "tools/test.py", line 153, in <module>
    main()
  File "tools/test.py", line 132, in main
    model.cuda(),
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 354, in _apply
    module._apply(fn)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 376, in _apply
    param_applied = fn(param)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/nn/modules/module.py", line 458, in <lambda>
    return self._apply(lambda t: t.cuda(device))
RuntimeError: CUDA error: out of memory
Traceback (most recent call last):
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/distributed/launch.py", line 261, in <module>
    main()
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/distributed/launch.py", line 257, in main
    cmd=cmd)
subprocess.CalledProcessError: Command '['/home/robert-kidder/miniconda3/envs/saic-vul/bin/python3', '-u', 'tools/test.py', '--local_rank=7', 'configs/imvoxelnet/imvoxelnet_kitti.py', 'checkpoints/KITTI/20210503_214214.pth', '--launcher', 'pytorch', '--eval', 'mAP']' returned non-zero exit status 1.

@Geralt-of-winterfall
Copy link
Author

The commad:

python tools/test.py configs/imvoxelnet/imvoxelnet_kitti.py checkpoints/KITTI/20210503_214214.pth --show --show-dir ./show_dirs/test/

the output:

[                                                  ] 0/2, elapsed: 0s, ETA:Traceback (most recent call last):
  File "tools/test.py", line 153, in <module>
    main()
  File "tools/test.py", line 129, in main
    outputs = single_gpu_test(model, data_loader, args.show, args.show_dir)
  File "/home/robert-kidder/桌面/3D_Object_Detection/ImVoxelnet/imvoxelnet/mmdet3d/apis/test.py", line 27, in single_gpu_test
    for i, data in enumerate(data_loader):
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 363, in __next__
    data = self._next_data()
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 989, in _next_data
    return self._process_data(data)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1014, in _process_data
    data.reraise()
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/_utils.py", line 395, in reraise
    raise self.exc_type(msg)
KeyError: Caught KeyError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/robert-kidder/miniconda3/envs/saic-vul/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/robert-kidder/桌面/3D_Object_Detection/ImVoxelnet/imvoxelnet/mmdet3d/datasets/custom_3d.py", line 292, in __getitem__
    return self.prepare_test_data(idx)
  File "/home/robert-kidder/桌面/3D_Object_Detection/ImVoxelnet/imvoxelnet/mmdet3d/datasets/custom_3d.py", line 166, in prepare_test_data
    input_dict = self.get_data_info(index)
  File "/home/robert-kidder/桌面/3D_Object_Detection/ImVoxelnet/imvoxelnet/mmdet3d/datasets/kitti_monocular_dataset.py", line 12, in get_data_info
    info = self.data_infos[index]
KeyError: 0

@Geralt-of-winterfall
Copy link
Author

How can I test the pre-trained model with the input of image?
For example, similar to the command in mmDetection3D:

python demo/mono_det_demo.py ${IMAGE_FILE} ${ANNOTATION_FILE} ${CONFIG_FILE} ${CHECKPOINT_FILE} [--device ${GPU_ID}] [--out-dir ${OUT_DIR}] [--show]

#by me
python tools/test.py configs/imvoxelnet/imvoxelnet_2xb4_sunrgbd-3d-10class.py checkpoints/imvotenet_faster_rcnn_r50_fpn_2x4_sunrgbd-3d-10class_20210819_225618-62eba6ce.pth --show --show-dir ./outputs/test/ --task mono_det

However, it doesn't work because of the bug https://github.com/open-mmlab/mmdetection3d/issues/2723#issue-1888575712
I just want the results of the Monocludar 3D Object Detection indoor.
Thank you!

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

2 participants