open-mmlab / mmfewshot

OpenMMLab FewShot Learning Toolbox and Benchmark
https://mmfewshot.readthedocs.io/en/latest/
Apache License 2.0
698 stars 118 forks source link

RuntimeError: The expanded size of the tensor (21) must match the existing size (54) at non-singleton dimension 0. Target sizes: [21, 1024]. Tensor sizes: [54, 1024] #29

Closed Williamlizl closed 2 years ago

Williamlizl commented 2 years ago

Traceback (most recent call last): File "/home/lbc/miniconda3/envs/mmfewshot/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/home/lbc/miniconda3/envs/mmfewshot/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/lbc/mmfewshot-main/tools/detection/misc/initialize_bbox_head.py", line 289, in <module> main() File "/home/lbc/mmfewshot-main/tools/detection/misc/initialize_bbox_head.py", line 278, in main args) File "/home/lbc/mmfewshot-main/tools/detection/misc/initialize_bbox_head.py", line 169, in random_init_checkpoint new_weight[:prev_cls] = pretrained_weight[:prev_cls] RuntimeError: The expanded size of the tensor (21) must match the existing size (54) at non-singleton dimension 0. Target sizes: [21, 1024]. Tensor sizes: [54, 1024]

The process of fsce on my own coco format datasets is:

  1. Base Training : ckpt(step1)
  2. step two: ues the best val pth of step 1 for train? python3.7 -m tools.detection.misc.initialize_bbox_head --src1 ./work_dirs/fsce_r101_fpn_coco_base-training/best_bbox_mAP_iter_105000.pth --method random_init --save-dir ./work_dirs/fsce_r101_fpn_coco-split1_base-training
linyq17 commented 2 years ago

For coco dataset, --coco needs to be attached.

Williamlizl commented 2 years ago

For coco dataset, --coco needs to be attached.

I need to change this? ./mmfewshot-main/tools/detection/misc/initialize_bbox_head.py COCO_NOVEL_CLASSES = [ 1, 2, 3, 4, 5, 6, 7, 9, 16, 17, 18, 19, 20, 21, 44, 62, 63, 64, 67, 72 ] COCO_BASE_CLASSES = [ 8, 10, 11, 13, 14, 15, 22, 23, 24, 25, 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 65, 70, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 89, 90

linyq17 commented 2 years ago

If using custom datasets, the pre-defined class ids need to be modified for your setting. If using default setting, you can run this command: python3 -m tools.detection.misc.initialize_bbox_head --src1 path/to/model --method random_init --save-dir path/to/dir --coco

linyq17 commented 2 years ago

TAR_SIZE is the number of classes in the output model.

Williamlizl commented 2 years ago

TAR_SIZE is the number of classes in the output model.

OSError: /work_dirs/fsce_r101_fpn_coco-split1_base-training/base_model_random_init_bbox_head.pth is not a checkpoint file Traceback (most recent call last):

fsce coco in the step 3: CUDA_VISIBLE_DEVICES=2,3 ./tools/detection/dist_train.sh ./configs/detection/fsce/coco/fsce_r101_fpn_coco_10shot-fine-tuning.py 2

BIGWangYuDong commented 2 years ago

If you still meet this error, you can create a new issue