ucbdrive / few-shot-object-detection

Implementations of few-shot object detection benchmarks
Apache License 2.0
1.1k stars 223 forks source link

Checkpoint Surgery remove method yield "AttributeError: 'Namespace' object has no attribute 'param_name'" #114

Closed Jeanbouvatt closed 3 years ago

Jeanbouvatt commented 3 years ago

I try to fine-tune model for few shot detection, according to instructions I have to remove last layer to retrain it.

python -m tools.ckpt_surgery \
    --src1 checkpoints/custom_dataset/faster_rcnn/faster_rcnn_R_101_FPN_base1/model_final.pth \
    --method remove \
     --save-dir checkpoints/custom_dataset/faster_rcnn/faster_rcnn_R_101_FPN_all1 \
    --coco

However it fails

Traceback (most recent call last):
  File "/home/me/miniconda3/envs/fsdet/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/me/miniconda3/envs/fsdet/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/me/few-shot-object-detection/tools/ckpt_surgery.py", line 260, in <module>
    ckpt_surgery(args)
  File "/home/me/few-shot-object-detection/tools/ckpt_surgery.py", line 78, in ckpt_surgery
    surgery_loop(args, surgery)
  File "/home/me/few-shot-object-detection/tools/ckpt_surgery.py", line 152, in surgery_loop
    for param_name in args.param_name:
AttributeError: 'Namespace' object has no attribute 'param_name'
Process finished with exit code 1

I tried it with and without --coco and it still fails. When digging the code, it seems to be looking for param name to remove from model, however I do not know the layer param name. It does not seems to be an option in the argparser either.

Jeanbouvatt commented 3 years ago

[Solved] Problem was from a undetected custom modification from my side, vanilla code work as intended when reverting, sorry for the trouble