open-mmlab / mmsegmentation

OpenMMLab Semantic Segmentation Toolbox and Benchmark.
https://mmsegmentation.readthedocs.io/en/main/
Apache License 2.0
8.27k stars 2.62k forks source link

out_channels for multiclass segmentation, softmax probability threshold. (principiant!! please send help) #3448

Open ale2sia opened 11 months ago

ale2sia commented 11 months ago

Hi, I'm a beginner student in neural network design. For a university assignment, I need to program an artificial intelligence network to segment cellular images, identifying cells, borders, and background. I have some questions because, being inexperienced, I didn't quite understand from the MMSegmentation documentation.

  1. I'm not sure if in my case num_classes = 3 and out_channels = 3. I'm unsure whether out_channels is the number of classes for segmentation or the number of layers in the output mask. So, I don't understand if it should be set to 1 or 3.
  2. I'm unsure how to adjust the softmax; I would like to raise the segmentation threshold to reduce over-segmentation issues, but I don't understand how to access the softmax.
  3. In general, when providing segmentation masks for training the network, can these be in 8-bit? Today, a fellow student told me they must necessarily have values between 0 and 1, and I don't understand if this is true or if there's a setting to decide what the newtorks expects me to supply for the training.

Please be patient; this is my very first experience in programming. Also, I'm not cheating! Our professor told us to use all the resources available to us to better understand things. Thank you!

PS. I am using a type='PSPHead' as decode_head, the auxiliary_head is a type='FCNHead' and the backbone type='ResNetV1c'

xiexinch commented 11 months ago

Hi @ale2sia,

  1. Usually, It's not necessary to set the out_channels, in a multi-class segmentation task, you only need to set the num_classes value.
  2. In training, whether use softmax depend on the loss function, e.g, https://github.com/open-mmlab/mmsegmentation/blob/main/mmseg/models/losses/cross_entropy_loss.py#L45. In testing, we use argmax method to classify the class of a pixel. https://github.com/open-mmlab/mmsegmentation/blob/main/mmseg/models/segmentors/base.py#L188
  3. I don't quite understand your third question. Usually what you want the network to learn should be determined by your loss function, or objective function. The label for semantic segmentation is usually the mask of the category index to which each pixel belongs to.