skyhehe123 / SA-SSD

SA-SSD: Structure Aware Single-stage 3D Object Detection from Point Cloud (CVPR 2020)
492 stars 106 forks source link

Pretrained Model #49

Closed wangzhangfei-hkd closed 4 years ago

wangzhangfei-hkd commented 4 years ago

Dear author, when I run the program, I have the following problems:

(pc) seivl@seivl-Default-string:~/SA-SSD/tools$ python3 test.py ../configs/car_cfg.py ../saved_model_vehicle/epoch_50.pth 
/home/seivl/anaconda3/envs/pc/lib/python3.6/site-packages/numba/cuda/envvars.py:17: NumbaWarning: 
Environment variables with the 'NUMBAPRO' prefix are deprecated and consequently ignored, found use of NUMBAPRO_NVVM=/usr/local/cuda/nvvm/lib64/libnvvm.so.

For more information about alternatives visit: ('http://numba.pydata.org/numba-doc/latest/cuda/overview.html', '#cudatoolkit-lookup')
  warnings.warn(errors.NumbaWarning(msg))
/home/seivl/anaconda3/envs/pc/lib/python3.6/site-packages/numba/cuda/envvars.py:17: NumbaWarning: 
Environment variables with the 'NUMBAPRO' prefix are deprecated and consequently ignored, found use of NUMBAPRO_LIBDEVICE=/usr/local/cuda/nvvm/libdevice.

For more information about alternatives visit: ('http://numba.pydata.org/numba-doc/latest/cuda/overview.html', '#cudatoolkit-lookup')
  warnings.warn(errors.NumbaWarning(msg))
/home/seivl/anaconda3/envs/pc/lib/python3.6/site-packages/numba/cuda/envvars.py:17: NumbaWarning: 
Environment variables with the 'NUMBAPRO' prefix are deprecated and consequently ignored, found use of NUMBAPRO_CUDA_DRIVER=/usr/lib/x86_64-linux-gnu/libcuda.so.

For more information about alternatives visit: ('http://numba.pydata.org/numba-doc/latest/cuda/overview.html', '#cudatoolkit-lookup')
  warnings.warn(errors.NumbaWarning(msg))
[40, 1600, 1408]
==> Loading parameters from checkpoint ../saved_model_vehicle/epoch_50.pth to GPU
Traceback (most recent call last):
  File "test.py", line 158, in <module>
    main()
  File "test.py", line 140, in main
    load_params_from_file(model, args.checkpoint)
  File "/home/seivl/SA-SSD/tools/train_utils/__init__.py", line 157, in load_params_from_file
    model_state_disk = checkpoint['model_state']
KeyError: 'model_state'

i changed it to model_state_disk = checkpoint['state_dict'] But the accuracy of the final detection results is very low, the results are as follows

Car AP@0.70, 0.70, 0.70:
bbox AP:0.07, 0.09, 0.12
bev  AP:0.00, 0.00, 0.00
3d   AP:0.00, 0.00, 0.00
aos  AP:0.03, 0.04, 0.05
Car AP@0.70, 0.50, 0.50:
bbox AP:0.07, 0.09, 0.12
bev  AP:0.04, 0.06, 0.07
3d   AP:0.02, 0.02, 0.02
aos  AP:0.03, 0.04, 0.05

How can I modify it to achieve the results of your paper. We look forward to your reply.

wangzhangfei-hkd commented 4 years ago

This problem has been solved. First, you need to train yourself, and then test it.

yangyongguang commented 4 years ago

i have meet the same problem and i do not understand what you mean. why should i need to train it again and than test it.

wangzhangfei-hkd commented 4 years ago

i have meet the same problem and i do not understand what you mean. why should i need to train it again and than test it.

Hi, After testing, directly using the weight file given by the author will report an error. You can get the weight file after training yourself, and then you can test it without error. Because I didn’t look at the code carefully, I still don’t know the difference between the two.

dimitree54 commented 4 years ago

It seems that they have changed names of some weights in newer versions, so to load provided pretrained model I had to change loading code a bit:

def load_params_from_file(model, filename, to_cpu=False):
       if not os.path.isfile(filename):
           raise FileNotFoundError

       print('==> Loading parameters from checkpoint %s to %s' % (filename, 'CPU' if to_cpu else 'GPU'))
       loc_type = torch.device('cpu') if to_cpu else None
       checkpoint = torch.load(filename, map_location=loc_type)
       model_state_disk = checkpoint['state_dict']  # LINE CHANGED

       if 'version' in checkpoint:
           print('==> Checkpoint trained from version: %s' % checkpoint['version'])

       update_model_state = {}
       for key, val in model_state_disk.items():
           new_key = "module." + key  # NEW LINE
           if new_key in model.state_dict() and model.state_dict()[new_key].shape == model_state_disk[key].shape:  # LINE CHANGED
               update_model_state[new_key] = val  # LINE CHANGED
               # logger.info('Update weight %s: %s' % (key, str(val.shape)))
       update_model_state['module.neck.point_fc.weight'] = model_state_disk['neck.backbone.point_fc.weight']  # NEW LINE
       update_model_state['module.neck.point_cls.weight'] = model_state_disk['neck.backbone.point_cls.weight']  # NEW LINE
       update_model_state['module.neck.point_reg.weight'] = model_state_disk['neck.backbone.point_reg.weight']  # NEW LINE

       state_dict = model.state_dict()
       state_dict.update(update_model_state)
       model.load_state_dict(state_dict)

       for key in state_dict:
           if key not in update_model_state:
               print('Not updated weight %s: %s' % (key, str(state_dict[key].shape)))

       print('==> Done (loaded %d/%d)' % (len(update_model_state), len(model.state_dict())))

With that code I am able to load a model and achieve accuracy metrics provided at main page (without any retraining).

AOOOOOA commented 2 years ago

I tried to use the original function block and the updated function, the results are all 0. I guess I need to re-train the model by myself. But when I run the train.py, there are errors. This model really cost me a lot of time to debug.

yangyongguang commented 2 years ago

您的邮件我已经收到了  我会及时的阅读 谢谢