Answers.Body: <p>You may find it useful to categorize these smaller defects as a separate class, then introduce a class weights matrix to penalize incorrect classification of the smaller defects more heavily. If these small defects represent a very small portion of the total number of pixels in your training data, then the model may be stuck at a local minimum, where it just predicts them as zero because the loss is not heavily penalized for this. So you need to add extra penalty for the incorrect classification.</p>
  <p>Assuming you create a new class for the small defects, the class weights matrix is implemented as a keras callback function.</p>
  <p>If you do not want to create a multiclass problem, there is also this paper : <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5977596/#!po=32.4561" rel="nofollow noreferrer">https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5977596/#!po=32.4561</a>
  The multilevel unet architecture will not solve class imbalance if that is truly the underlying issue, but if may make the network more aware of smaller scale changes in the images you're working with.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-24T09:22:25.820Z
Answers.Text: Hi, I already use kernel_regularizer which also penalizes the weights. Then what would be the difference between class_weight and kernel_regularizer.
Answers.UserDisplayName: shankar ram
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-24T18:49:52.780Z
Answers.Text: Edited. By class weights I mean a weight matrix applied as a callback during the final loss calculation, not a regularization layer.
Answers.UserDisplayName: nyomu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-23T23:26:06.830Z
Answers.LastActivityDate: 2020-11-24T18:48:25.220Z
Answers.LastEditDate: 2020-11-24T18:48:25.220Z
Answers.UserDisplayName: nyomu
Body: <p>I performed semantic segmentation with U-net. My dataset consists of grayscale images of defects. After training the dataset for I got an metric accuracy of only 0.3 - 0.4 IOU. Eventhough it is merely low it performs well enough to identify instances that are huge means the prediction performs well enough in places where there is a standard intensity change(color change) and they are bigger instances. There are many other instances where there is no color change and it occoupies only few pixels in image(smaller instances) and the prediction rate is almost 0 on these instances.</p>
  <p>I also tried Resdiual connection in the downsampling part of U-net likewise in ResNet. But still its the same and for smaller instances I used dilated convolution blocks in between the skip connections for encoder and decoder of U-net based on some papers. But still I cannot have a higher accuracy in my network and prediction rate for smaller instances are really poor. Although I use only 350 images for training with Data Augmentations. My image size is also 256,256.</p>
  <p>Is there any other method I can try to increase the accuracy and prediction rate for smaller instances?
  Any suggestion would be helpful.</p>
  
Tags: <deep-learning><convolutional-neural-networks><image-segmentation><u-net><binary-classification>
Title: Semantic segmentation failing in small instance detection
UserDisplayName: shankar ram
ThreadText: # Semantic segmentation failing in small instance detection
  
  (Asked by: username_0 on 2020-11-23)
  
  I performed semantic segmentation with U-net. My dataset consists of grayscale images of defects. After training the dataset for I got an metric accuracy of only 0.3 - 0.4 IOU. Eventhough it is merely low it performs well enough to identify instances that are huge means the prediction performs well enough in places where there is a standard intensity change(color change) and they are bigger instances. There are many other instances where there is no color change and it occoupies only few pixels in image(smaller instances) and the prediction rate is almost 0 on these instances.
  
  I also tried Resdiual connection in the downsampling part of U-net likewise in ResNet. But still its the same and for smaller instances I used dilated convolution blocks in between the skip connections for encoder and decoder of U-net based on some papers. But still I cannot have a higher accuracy in my network and prediction rate for smaller instances are really poor. Although I use only 350 images for training with Data Augmentations. My image size is also 256,256.
  
  Is there any other method I can try to increase the accuracy and prediction rate for smaller instances?
  Any suggestion would be helpful.
  
  **Tags:** deep-learning, convolutional-neural-networks, image-segmentation, u-net, binary-classification
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-23. Score: 0
  
  You may find it useful to categorize these smaller defects as a separate class, then introduce a class weights matrix to penalize incorrect classification of the smaller defects more heavily. If these small defects represent a very small portion of the total number of pixels in your training data, then the model may be stuck at a local minimum, where it just predicts them as zero because the loss is not heavily penalized for this. So you need to add extra penalty for the incorrect classification.
  
  Assuming you create a new class for the small defects, the class weights matrix is implemented as a keras callback function.
  
  If you do not want to create a multiclass problem, there is also this paper : <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5977596/#!po=32.4561>
  The multilevel unet architecture will not solve class imbalance if that is truly the underlying issue, but if may make the network more aware of smaller scale changes in the images you're working with.
  
  > **Comments:**
  > **username_0**: Hi, I already use kernel_regularizer which also penalizes the weights. Then what would be the difference between class_weight and kernel_regularizer.  
  > **username_1**: Edited. By class weights I mean a weight matrix applied as a callback during the final loss calculation, not a regularization layer.  
  
  ---
  
  