MCG-NJU/MixFormerV2

RuntimeError: Sizes of tensors must match except in dimension 0. Got 1 and 2 (The offending index is 1)

Cyraneon opened this issue · 4 comments

Hi,

When running a test on a short sequence of less than 200 frames, there is no issue at all. But for some reason, as soon as the 201st frame is processed, I get the error described futher down this post.

In tracking/test_mixformer.sh is written the following :
python tracking/test.py mixformer2_vit_online 288_depth8_score \ --dataset got10k_test --threads 1 --num_gpus 1 \ --params__model models/mixformerv2_base.pth.tar \ --params__search_area_scale 5.0 \ --debug 1

And launching this command ends up in getting the following error when the 201st frame is processed :
`"""
Traceback (most recent call last):
File "/media/phebe_storage/users/de-faria_isl.fr/test_trackers/MixFormerV2/.conda/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/media/phebe_storage/users/de-faria_isl.fr/test_trackers/MixFormerV2/.conda/lib/python3.6/multiprocessing/pool.py", line 47, in starmapstar
return list(itertools.starmap(args[0], args[1]))
File "tracking/../lib/test/evaluation/running.py", line 133, in run_sequence
output = tracker.run_sequence(seq, debug=debug)
File "tracking/../lib/test/evaluation/tracker.py", line 90, in run_sequence
output = self._track_sequence(tracker, seq, init_info)
File "tracking/../lib/test/evaluation/tracker.py", line 145, in _track_sequence
out = tracker.track(image, info)
File "tracking/../lib/test/tracker/mixformer2_vit_online.py", line 98, in track
out_dict = self.network(self.template, self.online_template, search, softmax=True, run_score_head=True)
File "/media/phebe_storage/users/de-faria_isl.fr/test_trackers/MixFormerV2/.conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 729, in _call_impl
result = self.forward(*input, **kwargs)
File "tracking/../lib/models/mixformer2_vit/mixformer2_vit_online.py", line 333, in forward
template, online_template, search, reg_tokens, distill_feat_list = self.backbone(template, online_template, search)
File "/media/phebe_storage/users/de-faria_isl.fr/test_trackers/MixFormerV2/.conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 729, in _call_impl
result = self.forward(*input, **kwargs)
File "tracking/../lib/models/mixformer2_vit/mixformer2_vit_online.py", line 238, in forward
x = torch.cat([x_t, x_ot, x_s, reg_tokens], dim=1) # (b, hw+hw+HW+4, embed_dim)
RuntimeError: Sizes of tensors must match except in dimension 0. Got 1 and 2 (The offending index is 1)
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "tracking/test.py", line 72, in
main()
File "tracking/test.py", line 68, in main
args.threads, num_gpus=args.num_gpus, tracker_params=tracker_params)
File "tracking/test.py", line 34, in run_tracker
run_dataset(dataset, trackers, debug, threads, num_gpus=num_gpus)
File "tracking/../lib/test/evaluation/running.py", line 182, in run_dataset
pool.starmap(run_sequence, param_list)
File "/media/phebe_storage/users/de-faria_isl.fr/test_trackers/MixFormerV2/.conda/lib/python3.6/multiprocessing/pool.py", line 274, in starmap
return self._map_async(func, iterable, starmapstar, chunksize).get()
File "/media/phebe_storage/users/de-faria_isl.fr/test_trackers/MixFormerV2/.conda/lib/python3.6/multiprocessing/pool.py", line 644, in get
raise self._value
RuntimeError: Sizes of tensors must match except in dimension 0. Got 1 and 2 (The offending index is 1)`

Any idea of how to fix this issue ?

Thanks in advance !

Hi, thanks for your attention!
I checked the code and found the problem. Now this version of code can only support test with online size 1, otherwise this issue will occur.
You can set it in the config file experiments\mixformer2_vit_online\288_depth8_score.yaml:

TEST:
  ONLINE_SIZES:
    ...
    GOT10K_TEST: [1]

I will correct the config to avoid mistake and a version of code that supports multiple templates inference is in preparation and will be released when ready.

Thanks a lot for your response!

It worked