mkang315 / RCS-YOLO

[MICCAI'23] Official implementation of "RCS-YOLO: A Fast and High-Accuracy Object Detector for Brain Tumor Detection".
GNU General Public License v3.0
75 stars 10 forks source link

RuntimeError: Given input size: (384x40x42). Calculated output size: (384x0x1). Output size is too small #12

Open Kao404 opened 6 months ago

Kao404 commented 6 months ago

Dear blogger, after training an epoch, there is an error, what is the reason and how to solve it?

mkang315 commented 5 months ago

The spatial size of your input images is too small for any YOLO model. You could try to resize the images to the original input size (640x640) of our model or modify our code to create a custom model suitable for your image size.

lanhuiling01 commented 3 months ago

The spatial size of your input images is too small for any YOLO model. You could try to resize the images to the original input size (640x640) of our model or modify our code to create a custom model suitable for your image size.输入图像的空间大小对于任何 YOLO 模型来说都太小。您可以尝试将图像大小调整为我们模型的原始输入大小 (640x640),或修改我们的代码以创建适合您的图像大小的自定义模型。

Why does the code report this error when testing the test set after training? When I fixed the picture to 640, the error was still reported, please help me

mkang315 commented 3 months ago

This reported error occurs when kernel_size is bigger than its input_size in nn.AvgPool2d() or nn.MaxPool2d() function. The reason is when using ceil_mode=True, maxpool might return a dimension of 2 instead of 1, causing dimension mismatch. Switched to using ceil_mode=False or torch.max.

References: https://discuss.pytorch.org/t/given-input-size-512x1x1-calculated-output-size-512x0x0-output-size-is-too-small/111071 https://github.com/leehanchung/cs224n/tree/2a4af4f556f361fc5c953bfe3f57c1b7c01a0da4/a5_public https://github.com/pytorch/pytorch/issues/28625#issue-512206689 https://github.com/pytorch/pytorch/issues/26610#issue-496710180

hahahaa1 commented 3 months ago

In the code, the default value of ceil_mode is already false. I don't know how to solve this error. How should I make the modification?