-
Notifications
You must be signed in to change notification settings - Fork 19
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
Multiple class output #95
Comments
Can you specify a bit more what exactly you want to do?
Both options are in principle supported, semantic segmentation is fairly easy, semantic instance segmentation is a bit more complex (and there are potentially multiple options for tackling it). |
In general, I have 2D (2 channels) data from experiments where I classify objects into one of 11 classes (I also have labeling where each object has its number). I would like to train the network first to reproduce the output of my current algorithm (deterministic), then manually reduce bugs and retrain the net. So it looks like the first option (translate to the second one could be done with connected components algorithm in case of my data). I base on sample code from the readme. (I just noticed that I do not think about Sample data (channel axis is 0): |
Yes, indeed, this looks like you can approach it with semantic segmentation.
The simplest approach is to convert the labels to a one-hot encoding, then you can use almost the same code as in the sample code from the readme; you just need to change the number of output channels in your network to the number of classes. To get the one hot encoding you can use https://github.com/constantinpape/torch-em/blob/main/torch_em/transform/label.py#L150, as For some background: the default code will use a dice coefficient based loss, which requires a one-hot encoded target. You could also use cross entropy loss (from pytorch directly), which would not need the one-hot encoded target. But the dice loss is more robust against sparse classes (i.e. small fraction of foreground pixels) and usually works better for microscopy data. Let me know if you run into any issues. |
In general the biggest question here is what kind of data you're training the network on, and if the task you want to learn is feasible given the data and labels. This is all very data dependent, so without any real knowledge about the data and/or labels here are some general observations and things I observe in the screenshots:
|
These data are different stages of converting neutrophils to neutrophils net base on time and concentration of ecola bacteria. So images from different time points contain a different proportion of different class representatives. I could share more details, but on a more private channels (ex. mail, napari zulip chat etc)
92 images in train set and 30 in test set, annotated using a deterministic algorithm. It is to low?
Data has two channels, so not only the shape, detected from the main channel, is important. But as these are
This is the unspecific binding of the probe (added to segmentation for faster predicting potentially problematic images). I see that maybe I do not select enough good images. I will add the next screenshot tomorrow. |
Sorry for the extended response. Each time I start writing the next question and need to fully formulate it, I find the next step that needs to be done. Finally, I got things working, and it looks nice. Did you know a way to get universal information about the number of input channels from the model exported to bioimage io format? |
If I correctly go through the code currently only object segmentation is supported and there is no support for assigning objects to one of the predefined class?
If I'm wrong could you point me how to do this. Or maybe it is possible to somehow modify code to achieve this?
The text was updated successfully, but these errors were encountered: