bigmb / Unet-Segmentation-Pytorch-Nest-of-Unets

Implementation of different kinds of Unet Models for Image Segmentation - Unet , RCNN-Unet, Attention Unet, RCNN-Attention Unet, Nested Unet
MIT License
1.87k stars 345 forks source link

Question about output channel #11

Closed mobassir94 closed 4 years ago

mobassir94 commented 4 years ago

Does output channel means number of class? if i use output channel = 4 that means number of class = 4?

my dataloader and baseline model is different but i want to use models from this repository,any other demo of this repository work in a single notebook would help a lot,thanks in advance

bigmb commented 4 years ago

Yes. Out channel means output classes. But here you will have to write the softmax activation as I have taken the case of binary output.

Any other model will work as well. Just add the models in model folder and change it in pytorch_run.

mobassir94 commented 4 years ago

i was trying to use nested unet from this repository but i see in models.py you have :

final_forward

def forward(self, x):
    c00, c0 = self.contractive_0(x)
    c11, c1 = self.contractive_1(c0)
    c22, c2 = self.contractive_2(c1)
    c33, c3 = self.contractive_3(c2)
    bottle = self.bottleneck(c3)
    u3 = F.relu(self.expansive_3(bottle, c33))
    u2 = F.relu(self.expansive_2(u3, c22))
    u1 = F.relu(self.expansive_1(u2, c11))
    u0 = F.relu(self.expansive_0(u1, c00))
    return F.softmax(self.output(u0), dim=1)

you are using softmax here,where should i make change so that i replace sigmoid to softmax?

One more question : i am working on this competition : https://www.kaggle.com/c/severstal-steel-defect-detection

i have cloned this repository and uploaded it in kaggle then using this command :

!cp -r ../input/pytorch-unet-segmentation/Unet-Segmentation-Pytorch-Nest-of-Unets-master/* ./

i can use all your models in kaggle kernel,as my dataset containing 4 class and 3 channel what are the changes i need to make to use nested unet from this repository? is there any way to use nested unet from this repository with efficientnetb3 as backbone encoder?

bigmb commented 4 years ago

That is for dict use of Unet. I have yet to check the complete output of it. For nested Unet the output is sigmoid, as defined in pytorch_run file.

You need to change some places to make it a 4 channel. And the activation function to softmax (line 299 i think) in the pyotrch_run file.

Yes you can. Just add the pytorch model in Models file and provide the output as the other models.

mobassir94 commented 4 years ago

found it : pred_tb = F.sigmoid(pred_tb) in line number 299 i will change it,but if you could change specifically what are some other lines where i will have to change then it would be highly appreciated,thanks