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

Adaptation to Multiclass Segmentation #5

Open
vminin2000 opened this issue Apr 10, 2022 · 0 comments
Open

Adaptation to Multiclass Segmentation #5

vminin2000 opened this issue Apr 10, 2022 · 0 comments

Comments

@vminin2000
Copy link

Hi! I hope to leave a public record here to help others that are struggling to convert binary semantic segmentation code to multi-class semantic segmentation code. I reached out to you and have done other research as to how to go about adapting your code and I have come to the conclusion that I must change the deeplabv3_plus function definition's last four lines of code to be this

x = Conv2D(4,(1, 1))(x) ## 4 is the number of classes
x = Activation("softmax")(x) ## The activation function has been changed from sigmoid to softmax
model = Model(inputs, x)
return model

Then the loss function must be changed as well, I found recommendations to change it to CrossEntropyLoss. The adaptation occurs in the train.py file on line 99

criterion = torch.nn.CrossEntropyLoss()
model.compile(loss=dice_loss, optimizer=Adam(lr), metrics=[dice_coef, iou, Recall(), Precision()])

I believe the metrics must be changed also to Jaccard Score (IOU), and Dice Score.

I am receiving errors such as shapes being incorrect once I attempt to train the model and I am not sure what tensor object to insert in the loss function. If there is any advice you can give that'd be much appreciated. I know by myself and many others. Thanks!

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

1 participant