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

Is multiclass segmentation possible? #19

Closed
dev-walter opened this issue Mar 4, 2021 · 19 comments
Closed

Is multiclass segmentation possible? #19

dev-walter opened this issue Mar 4, 2021 · 19 comments

Comments

@dev-walter
Copy link

Hello,

I want to implement your model in a cell segmentation task. Since I have to segment my images into 4 classes (background, healthy cells, cancer cells and leucocytes) I wanted to ask if your model can be easily modified to support multiclass segmenation.
I have little experience in deep learning and python so help would be much appreciated!

@kabbas570
Copy link

Hello,
yes, you can change, add the following line, at the end of the model's last convolutional layer,
conv10 = conv2d_bn(mresblock9, 4, 1, 1, activation='sigmoid')
in the original model, this is 1 (number of classes), just change it to 4, your model can now predict four classes.

@nibtehaz
Copy link
Owner

nibtehaz commented Mar 8, 2021

Hi @dev-walter , thanks for your interest in our project.

Thank you @kabbas570 for resolving the issue.

@dev-walter
Copy link
Author

Hello,
yes, you can change, add the following line, at the end of the model's last convolutional layer,
conv10 = conv2d_bn(mresblock9, 4, 1, 1, activation='sigmoid')
in the original model, this is 1 (number of classes), just change it to 4, your model can now predict four classes.

Thank you this worked perfectly and the model performed very well :).

@nibtehaz
Copy link
Owner

Really glad to hear that @dev-walter , best wishes for you

@saskra
Copy link

saskra commented Oct 21, 2021

I have to segment my images into 4 classes (background, healthy cells, cancer cells and leucocytes)

add the following line, at the end of the model's last convolutional layer, conv10 = conv2d_bn(mresblock9, 4, 1, 1, activation='sigmoid') in the original model, this is 1 (number of classes), just change it to 4, your model can now predict four classes.

Thank you very much, I will test that too. But is the change from 1 to 4 really correct? There was already a background before, so there have always been 2 classes. [Edit: I think I understand it now. With one class plus background, you get the probability of it being the other class, sort of inclusive. Starting from two classes plus background you have to output it explicitly.]

Are there actually any other changes that have become mandatory, e.g. is the Jaccard index in its current form defined for multiclass predictions?

@nibtehaz
Copy link
Owner

Thanks @saskra . Yes for 2 class the background is just the opposite prediction probability. Nevertheless, you can work with 2 class using 2 output classes, but that’s kind of redundant.

in regards to evolution metrics, you can either collapse them to one dimension or class or compute them individually.

hope this helps, best wishes.

@hendriramdan
Copy link

hendriramdan commented Jul 15, 2022

Hello, sir.
i'm trying to predict multi class.
in my case, there are 3 classes.
i have changed the number 1 in con_10 to 3 according to the class i have. but i get an error like below:
Logits and labels must have the same shape ((1, 192, 256, 3) vs (1, 192, 256, 1)).
can anyone help me? which part should be changed?
thanks

@kabbas570
Copy link

Hi,
change to this..line 192.
conv10 = conv2d_bn(mresblock9, num_calsses=3, 1, 1, activation='sigmoid')

@kabbas570
Copy link

If you already did this, then check your target shape.

@hendriramdan
Copy link

hendriramdan commented Jul 15, 2022 via email

@kabbas570
Copy link

check your target shape it can be anywhere according to your implementation. for the code demo check this,
print(Y_train.shape)

@hendriramdan
Copy link

hendriramdan commented Jul 15, 2022 via email

@kabbas570
Copy link

There is some problem with your ground truth data, then, check it before feeding it to the model.

@hendriramdan
Copy link

hendriramdan commented Jul 15, 2022

I made ground truth data like this, is there something wrong with my method?
image

@kabbas570
Copy link

image

@kabbas570
Copy link

arrange your ground truth like this, I hope it will help.

@hendriramdan
Copy link

hendriramdan commented Jul 15, 2022

I apologize.
when am I exemplified with the original image data?

because in my case, there will divide in 1 image by 3 classes.
is this possible?
thank you very much.

@hendriramdan
Copy link

hendriramdan commented Oct 11, 2022 via email

@nibtehaz
Copy link
Owner

Hi Hendri, if you want to generate 3 class label, I would suggest you to make the Y_train.shape (56,192,256,3) (or (56,192,256,4) if you wish to have background)

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

5 participants