LeeJunHyun / Image_Segmentation

Pytorch implementation of U-Net, R2U-Net, Attention U-Net, and Attention R2U-Net.
2.68k stars 595 forks source link

Dataset training #27

Closed loaysh2010 closed 5 years ago

loaysh2010 commented 5 years ago

Hello, @LeeJunHyun I followed your instruction by changing the path to my data in dataset.py L99,100 .. but after running main.py i got errors in L152(solver.py) about the unequal size of SR_Flat, GT_Flat !!

ValueError: Target and input must have the same number of elements. target nelement (196608) != input nelement (65536)

LeeJunHyun commented 5 years ago

Hello, @loaysh2010 . You should use same size of ground truth. Please check SR_Flat and GT_Flat size.

loaysh2010 commented 5 years ago

@LeeJunHyun , Thank you very much for your concern. Actually, I did check SR_Flat and GT_Flat size. the input image and GT image are the same size [1,3,256,256], but the SR image is [1,1,256,256], so I convert the GT image to grayscale [1,1,256,256] after flatting it be the same this. I hope that will overcome the problem. Do you have any other idea?

LeeJunHyun commented 5 years ago

@loaysh2010 , I think your GT has 3 classes. If I am correct, then you should change the number of output channel of network.

loaysh2010 commented 5 years ago

@LeeJunHyun my GT was saved as png colored image. so it has the shape of [1,3,256,256] where 3 is for RGB colors. So after converting it to grayscale it's shaped become [1,1,256,256] so when flatting it get the same size as SR flatted image. do you think to change the number of output channel of the network better than convert the GT to grayscale with the previously mentioned shape ??

LeeJunHyun commented 5 years ago

If your GT has RGB channel, each channel must have its own meaning, right? If so, it would be batter that you just keep GT as colored image.

loaysh2010 commented 5 years ago

@LeeJunHyun Changed the output channel for the model to 3. and error fixed Thanks for your time. You can close the issue

soans1994 commented 3 years ago

hello author,

how can i use your code for mutliclass segmentation. i have rgb ground truth. thank you