forward() got an unexpected keyword argument 'with_pooling'
original-milk-tea opened this issue · 3 comments
Dear Dr.Du, thanks for your great job! I installed the environment according to the instructions in the readme, but when I ran python train.py, the following error occurred:
===> Refer-KITTI (train) <===
Number of identities: 475
========== Training (Text-Guided OFF) ==========
Traceback (most recent call last):
File "train.py", line 88, in
logits = model(inputs, epoch)['logits']
File "/home/zzz/miniconda3/envs/iKUN_Git/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/zzz/miniconda3/envs/iKUN_Git/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 171, in forward
outputs = self.parallel_apply(replicas, inputs, kwargs)
File "/home/zzz/miniconda3/envs/iKUN_Git/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 181, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/home/zzz/miniconda3/envs/iKUN_Git/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 89, in parallel_apply
output.reraise()
File "/home/zzz/miniconda3/envs/iKUN_Git/lib/python3.8/site-packages/torch/_utils.py", line 644, in reraise
raise exception
TypeError: Caught TypeError in replica 0 on device 0.
Original Traceback (most recent call last):
File "/home/zzz/miniconda3/envs/iKUN_Git/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 64, in _worker
output = module(*input, **kwargs)
File "/home/zzz/miniconda3/envs/iKUN_Git/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/zzz/Code/iKUN/model.py", line 267, in forward
visual_feat = self.visual_local_global(x['local_img'], x['global_img'])
File "/home/zzz/Code/iKUN/model.py", line 335, in visual_local_global
local_feat = self.clip.visual(local_img, with_pooling=False) # [bt,c,7,7]
File "/home/zzz/miniconda3/envs/iKUN_Git/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
TypeError: forward() got an unexpected keyword argument 'with_pooling'
looking forward to your reply, thanks!
Hi, thanks for your interest in our work! Sorry for the mistake, it seems a bug.
Indeed, we use ResNet50 for visual encoder, not ViT:
Line 26 in dc8a529
And it seems that I modified the source code of CLIP, but I have forgot it. 😂😂😂
Specifically, I modified the function ModifiedResNet.forward()
by adding the param with_pooling
:
def forward(self, x, with_pooling=True):
def stem(x):
for conv, bn in [(self.conv1, self.bn1), (self.conv2, self.bn2), (self.conv3, self.bn3)]:
x = self.relu(bn(conv(x)))
x = self.avgpool(x)
return x
x = x.type(self.conv1.weight.dtype)
x = stem(x)
x = self.layer1(x)
x = self.layer2(x)
x = self.layer3(x)
x = self.layer4(x)
if with_pooling:
x = self.attnpool(x)
return x
Please let me know if this helps~
This really worked. Thanks for your kind help!