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

torch.cat error in evaluation #19

Open
lianqiann opened this issue Apr 12, 2024 · 2 comments
Open

torch.cat error in evaluation #19

lianqiann opened this issue Apr 12, 2024 · 2 comments

Comments

@lianqiann
Copy link

I think the usage of torch.cat is wrong. And this would cause a runtime error

all_rand_shape = torch.cat([t['rand_shape'] for t in new_targets], 0)

When running eval script for COCO2017
python train_net.py --eval_only --resume --eval_get_content_features --num-gpus 8 --config-file /path/to/configs COCO.TEST.BATCH_SIZE_TOTAL=8 MODEL.WEIGHTS=/path/to/weights OUTPUT_DIR=/path/to/outputs

This would cause error that

all_rand_shape = torch.cat([t['rand_shape'] for t in new_targets], 0)
RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 800 but got size 896 for tensor number 1 in the list.

The tensors causing such error are in following shapes

torch.Size([30, 800, 1216])
torch.Size([2, 896, 800])
torch.Size([20, 800, 1088])
torch.Size([8, 1088, 800])

This issue will cause many other errors in many places, so fixing this alone cannot make the eval script run. Could anyone check on this? Thank you very much!

@lianqiann
Copy link
Author

i think the error is from that the targets size were not unified for inputs with different sizes. This issue only happens in non-training mode.

@FengLi-ust
Copy link
Contributor

Yes, in training we resize all images to a fixed size. For inference, using batch size 1 should work, otherwise you need to pad the images into the same size for batched inference.

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