'Other' class in Segmentation

Do we need to add an Other class in Segmentation?

Let me explain:
Say we are building a classification model that differentiates Dogs vs Cats, Jeremy taught us how to frame this as a MultiCategory problem such that when you upload an image of say a mountain, the model should return no label.

What about when I have trained a Semantic Segmentation model, that can segment Dogs vs Cats, how should I handle a situation where I upload an image that has neither a cat nor a dog and I want the model to not return any segmentation? Or a video where some frames have no cats or dogs and they show up in later frames?

Do I need to add random images that are not dogs or cats, then train the model with a blank segmentation or can the model handle this out of the box?

Any ideas or comments on how you’d approach this problem are highly welcome. Thanks in advance.

1 Like

Good question and one that I crossed paths with not very long ago when training my own segmentation model. In my case, I was trying to classify pixels on an athletic field. I only cared about where the white lines were on the field and everything else could be considered the ‘other’ class. When I was labeling my data using Gimp, I found a way to extract the white lines on the field and then turned everything else into ‘other’ or black in my case. This included the clouds, background stadium, track, green grass etc… The model actually worked very well with limited data provided to it. (~200 images). So in your case, you could mask everything except your dog & cat classes, then that would effectively give you 3 classes - dogs, cats, and other but you would have to modify and label your data accordingly.


Hey Tom.

I kinda get what you are implying by this:

I think fastai uses this approach too, because when predicting using the unet learner, as explained by Zach here: Binary Segmentation | walkwithfastai.

My only worry is whether the model can recognize the background class when its just by itself. I guess the best way forward is to just actually create this model and see how it performs.

I’ll report back on how it goes.

Thanks for your response btw :slight_smile: