How to prepare labels for multi-class segmentation #6168
Unanswered
hermancollin
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Hi @hermancollin, thanks for your interest here. Could you show me the whole error message? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I am struggling to train a 2D UNet segmentation model using monai. We work with microscopy images and want the model to predict 2 classes (3 if you count the background). So far, here is the material I based my training script on:
However the training doesn't work. I'm concerned that I'm mishandling the labels?
I use a dictionary to align the inputs and the labels. Note that I use 2 different keys for the 2 labels:
Training/validation transforms:
Load the images in a preliminary
Dataset
, then transform it toGridPatchDataset
:Define the 2-class segmentation model
Metric and loss:
Post-transforms:
Inside the training loop, I stack the 2 labels together to create a single 2-channel ground-truth. I do this to match the output of the model, which has size
[B, 2, H, W]
for 2 output channels.For validation, I pretty much do the same thing:
Would anyone have any insight on what's the problem here? The model is not able to learn at all so I must be doing something wrong with the loss function and the validation metric but I'm a bit stuck right now. Should I try to one-hot encode the predictions and labels?
Beta Was this translation helpful? Give feedback.
All reactions