how to use SimMIMSwinTransformer model as backbone to do the downsteam task #784
Unanswered
YuchenGUOGYC
asked this question in
How-to
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I use the selfup model to train a swin-large model, then I try to use the it as a backbone in mmdetection, then I write config code like this:
model = dict(
backbone=dict(
delete=True, # Delete the backbone field in base
type='mmpretrain.SimMIMSwinTransformer', # Using SimMIMSwinTransformer from mmpretrain
arch='large',
img_size=256,
stage_cfgs=dict(block_cfgs=dict(window_size=12)),
pad_small_map=True,
init_cfg=dict(
type='Pretrained',
checkpoint=pretrained,
prefix='backbone.'),
#frozen_stages=4 #
), # The pre-trained weights of backbone network in mmpretrain have prefix='backbone.'. The prefix in the keys will be removed so that these weights can be normally loaded.
# Modify in_channels
neck=dict(
type='PAFPN',
in_channels=[128, 256, 512, 1024],
out_channels=256,
num_outs=5),)
then it report issue like below:
Traceback (most recent call last):
File "/home/ec2-user/oetz/github_x/github/roof-counting-mmd/build_ins/train.py", line 128, in
main()
File "/home/ec2-user/oetz/github_x/github/roof-counting-mmd/build_ins/train.py", line 124, in main
runner.train()
File "/opt/conda/envs/pytorch/lib/python3.9/site-packages/mmengine/runner/runner.py", line 1777, in train
model = self.train_loop.run() # type: ignore
File "/opt/conda/envs/pytorch/lib/python3.9/site-packages/mmengine/runner/loops.py", line 96, in run
self.run_epoch()
File "/opt/conda/envs/pytorch/lib/python3.9/site-packages/mmengine/runner/loops.py", line 113, in run_epoch
self.run_iter(idx, data_batch)
File "/opt/conda/envs/pytorch/lib/python3.9/site-packages/mmengine/runner/loops.py", line 129, in run_iter
outputs = self.runner.model.train_step(
File "/opt/conda/envs/pytorch/lib/python3.9/site-packages/mmengine/model/base_model/base_model.py", line 114, in train_step
losses = self._run_forward(data, mode='loss') # type: ignore
File "/opt/conda/envs/pytorch/lib/python3.9/site-packages/mmengine/model/base_model/base_model.py", line 361, in _run_forward
results = self(**data, mode=mode)
File "/opt/conda/envs/pytorch/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/ec2-user/oetz/github_x/github/roof-counting-mmd/build_ins/mmdet/models/detectors/base.py", line 92, in forward
return self.loss(inputs, data_samples)
File "/home/ec2-user/oetz/github_x/github/roof-counting-mmd/build_ins/mmdet/models/detectors/two_stage.py", line 160, in loss
x = self.extract_feat(batch_inputs)
File "/home/ec2-user/oetz/github_x/github/roof-counting-mmd/build_ins/mmdet/models/detectors/two_stage.py", line 110, in extract_feat
x = self.backbone(batch_inputs)
File "/opt/conda/envs/pytorch/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
TypeError: forward() missing 1 required positional argument: 'mask'
how I can solve it ?
Beta Was this translation helpful? Give feedback.
All reactions