Error in image size U-Net

조회 수: 5 (최근 30일)
Atallah Baydoun
Atallah Baydoun 2019년 9월 13일
댓글: Atallah Baydoun 2019년 9월 19일
I am trying to train a Unet for semantic segmentation.
My images sizes are X*Y*Z*5.
The X,Y, and Z are different between different images but the training is done using patches.
When the patch size is set to [64 64 32 5], the training runs successfully.
If I choose a patch size of higher X and Y dimensions such as [256 448 8 5], I got the error below:
Error using trainNetwork (line 165)
Unexpected image size: All images must have the same size.
Any thoughts ?

답변 (1개)

Sourav Bairagya
Sourav Bairagya 2019년 9월 18일
In U-Net, generally the patch sizes are determined in accordance with the subsequent max-pool layers, so that the down-sampling by factor of 2 at each max-pool layer goes smoothly and training goes well. Hence, to make the training smoother, it is important to determine a proper patch size and use the same for all input training samples irrespective of their original dimensions.
From the problem you are facing, it seems that your U-net architecture is defined to take the input patches of size (64X64X32). Hence, when you are trying feed patches of different size than this, it is throwing error.
If the network architecture is a pre-defined one, then you should use the defined input patch size for training.
If the network is defined by you, then you should change the input dimension in ‘imageInputLayer’ of ‘layers’ object to your desired one and then feed to ‘trainNetwork’ function.
Hope this will help you.
  댓글 수: 1
Atallah Baydoun
Atallah Baydoun 2019년 9월 19일
Thanks Sourav for your help.
I did some debugging, and it seems that with the current coding in Matlab, data augmentation using X and Y flipping to augment data.
Let us suppose that you have an image 320 * 460 * 40.
You set a patch sizw of 260 * 360 * 4.
During the random patch extraction process with data augmentation, Matlab will try to catch a patch of 360*260*4and 360>320 so we get the error.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by