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

请问是否可以使用其他预训练教师模型 #48

Open
changxin111 opened this issue Sep 12, 2022 · 3 comments
Open

请问是否可以使用其他预训练教师模型 #48

changxin111 opened this issue Sep 12, 2022 · 3 comments

Comments

@changxin111
Copy link

我用FCOS-GFL-R101的配置预训练了一个教师模型,并用教师训练了学生模型,基本达到了您论文的结果。
我想尝试使用其他的预训练模型训练教师,不知道可不可以,另外代码是不是需要修改某些部分,麻烦帮忙看一下,谢谢。

我对 LD/configs/ld/ld_r50_fcos_r101_1x.py 进行了更改,
teacher_config='configs/fcos/fcos_r101_caffe_fpn_gn-head_mstrain_640-800_2x_coco.py',
teacher_ckpt='configs/ld/fcos_r101_caffe_fpn_gn-head_mstrain_640-800_2x_coco-511424d6.pth'
并下载了mmdetection提供的预训练模型。

@changxin111
Copy link
Author

运行代码后出现了以下报错:

Traceback (most recent call last):
File "./tools/train.py", line 187, in
main()
File "./tools/train.py", line 183, in main
meta=meta)
File "/home/cx/LD/mmdet/apis/train.py", line 170, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 125, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
self.run_iter(data_batch, train_mode=True)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 30, in run_iter
**kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/parallel/distributed.py", line 46, in train_step
Traceback (most recent call last):
File "./tools/train.py", line 187, in
Traceback (most recent call last):
main()
File "./tools/train.py", line 183, in main
File "./tools/train.py", line 187, in
meta=meta)
File "/home/cx/LD/mmdet/apis/train.py", line 170, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 125, in run
main()
File "./tools/train.py", line 183, in main
meta=meta)
File "/home/cx/LD/mmdet/apis/train.py", line 170, in train_detector
epoch_runner(data_loaders[i], **kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
runner.run(data_loaders, cfg.workflow)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 125, in run
self.run_iter(data_batch, train_mode=True)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 30, in run_iter
Traceback (most recent call last):
File "./tools/train.py", line 187, in
**kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/parallel/distributed.py", line 46, in train_step
main()
File "./tools/train.py", line 183, in main
meta=meta)
File "/home/cx/LD/mmdet/apis/train.py", line 170, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 125, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
epoch_runner(data_loaders[i], **kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
self.run_iter(data_batch, train_mode=True)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 30, in run_iter
self.run_iter(data_batch, train_mode=True)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 30, in run_iter
**kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/parallel/distributed.py", line 46, in train_step
**kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/parallel/distributed.py", line 46, in train_step
output = self.module.train_step(*inputs[0], **kwargs[0])
output = self.module.train_step(*inputs[0], **kwargs[0]) File "/home/cx/LD/mmdet/models/detectors/base.py", line 247, in train_step

File "/home/cx/LD/mmdet/models/detectors/base.py", line 247, in train_step
output = self.module.train_step(*inputs[0], **kwargs[0])
File "/home/cx/LD/mmdet/models/detectors/base.py", line 247, in train_step
output = self.module.train_step(*inputs[0], **kwargs[0])
File "/home/cx/LD/mmdet/models/detectors/base.py", line 247, in train_step
losses = self(**data)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
losses = self(**data)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
losses = self(**data)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
losses = self(**data)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 84, in new_func
result = self.forward(*input, **kwargs)result = self.forward(*input, **kwargs)

File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 84, in new_func
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 84, in new_func
result = self.forward(*input, **kwargs)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 84, in new_func
return old_func(*args, **kwargs)
File "/home/cx/LD/mmdet/models/detectors/base.py", line 181, in forward
return old_func(*args, **kwargs)
return old_func(*args, **kwargs)
File "/home/cx/LD/mmdet/models/detectors/base.py", line 181, in forward
File "/home/cx/LD/mmdet/models/detectors/base.py", line 181, in forward
return old_func(*args, **kwargs)
File "/home/cx/LD/mmdet/models/detectors/base.py", line 181, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/home/cx/LD/mmdet/models/detectors/kd_one_stage.py", line 76, in forward_train
return self.forward_train(img, img_metas, **kwargs)
return self.forward_train(img, img_metas, **kwargs) File "/home/cx/LD/mmdet/models/detectors/kd_one_stage.py", line 76, in forward_train

File "/home/cx/LD/mmdet/models/detectors/kd_one_stage.py", line 76, in forward_train
gt_bboxes_ignore)
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 254, in forward_train
gt_bboxes_ignore)
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 254, in forward_train
gt_bboxes_ignore)
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 254, in forward_train
losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 164, in new_func
losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 164, in new_func
losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 164, in new_func
return self.forward_train(img, img_metas, **kwargs)
File "/home/cx/LD/mmdet/models/detectors/kd_one_stage.py", line 76, in forward_train
return old_func(*args, **kwargs)
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 204, in loss
return old_func(*args, **kwargs)
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 204, in loss
return old_func(*args, **kwargs)num_pos=num_pos)

File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 204, in loss
File "/home/cx/LD/mmdet/core/utils/misc.py", line 29, in multi_apply
num_pos=num_pos)
File "/home/cx/LD/mmdet/core/utils/misc.py", line 29, in multi_apply
gt_bboxes_ignore)
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 254, in forward_train
num_pos=num_pos)
File "/home/cx/LD/mmdet/core/utils/misc.py", line 29, in multi_apply
losses = self.loss(*loss_inputs, gt_bboxes_ignore=gt_bboxes_ignore)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 164, in new_func
return old_func(*args, **kwargs)
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 204, in loss
num_pos=num_pos)
File "/home/cx/LD/mmdet/core/utils/misc.py", line 29, in multi_apply
return tuple(map(list, zip(*map_results)))return tuple(map(list, zip(*map_results)))
return tuple(map(list, zip(*map_results)))

File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 57, in loss_single
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 57, in loss_single
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 57, in loss_single
return tuple(map(list, zip(*map_results)))
File "/home/cx/LD/mmdet/models/dense_heads/ld_fcos_head.py", line 57, in loss_single
4 * (self.reg_max + 1))4 * (self.reg_max + 1))

4 * (self.reg_max + 1))
RuntimeError: shape '[-1, 68]' is invalid for input of size 243200RuntimeError
: shape '[-1, 68]' is invalid for input of size 243200
RuntimeError: shape '[-1, 68]' is invalid for input of size 268800
4 * (self.reg_max + 1))
RuntimeError: shape '[-1, 68]' is invalid for input of size 243200
Traceback (most recent call last):
File "/home/.conda/envs/cx_ld/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/.conda/envs/cx_ld/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/torch/distributed/launch.py", line 260, in
main()
File "/home/.conda/envs/cx_ld/lib/python3.7/site-packages/torch/distributed/launch.py", line 256, in main
cmd=cmd)

@HikariTJU
Copy link
Owner

HikariTJU commented Sep 12, 2022

configs/fcos/fcos_r101_caffe_fpn_gn-head_mstrain_640-800_2x_coco.py 和 FCOS-GFL-R101
区别在于一个用FCOSHead,另一个用FCOSGFLHead,这两个除了一般分布没有任何区别
不改成一般分布是没办法用LD的

@changxin111
Copy link
Author

changxin111 commented Sep 12, 2022 via email

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