I'm trying to train an object detection model to detect some of playing cards for example it will detect 1,2,3, king, queen and jack.

And I'm making a class of not and I have put examples of other cards such as 4,5,6,7,8,9 but for me it doesn't make sense to make this additional class.

So how to solve the problem of detecting other kind of cards as an objects should I make this class or remove it and keep only the required classes?


1 Answer 1


In your case you have 3 options for training your model:

  1. Make a class for each card number, so 13 classes.
  2. Make a class for 1, 2, 3, king, queen, jack and one bucket class for "other", so 7 classes.
  3. Make a class for 1, 2, 3, king, queen, and jack, so 6 classes. And whenever the model is not confident of any, assume it is "other".

Best would be option 1.

Option 1 would be the more difficult to get data for because you need labelled data for more classes, but that should not be a problem because it seems you already have it.

Option 1 allows your model to classify all classes, and let's you achieve the same as option 2 with post processing (i.e. if predicted_class in [4,5,6,7,8,9] then "other").

Option 2 could work, but the numbers in the "other" class are just as different from each other as to 1, 2 and 3. To be able to make this distinction, the first intuition is that a "larger" model would be needed in comparison to option 1. This approach would be handy if the "other" class is not similar to the other classes. For example, a model that classifies sports cars, family cars, clown cars and "other vehicles" (i.e. tractors, bikes and trucks).

Option 3 is best left for tasks that the "other" class is not defined, or too large to model. For example, a model that classifies if the playing cards are Uno, or Poker, or Blitz, or "any other game" card. In this case, there are too many "other" types of game cards for you to label and model.

  • $\begingroup$ thank you for the answer, my problem is similar to the cards playing but the first number is not available, so by doing option 2, do i need the same number of data for class 'other ' or it should contain more examples than other classes ? for example 200 images for each class and 400 for other class ? $\endgroup$ Oct 23, 2020 at 7:05
  • $\begingroup$ @MustafaAzzurri do you know how many classes you are grouping into the "other" class? $\endgroup$ Oct 27, 2020 at 6:43
  • $\begingroup$ It's more similar to option 3 when there are too much other types of cards $\endgroup$ Oct 27, 2020 at 7:19
  • $\begingroup$ If it like option 3, then do not create an "other" class. When ever your model is not confident of any class, then assume it is the other class. Do not use softmax in the end of your model. Softmax ensures that the class probabilities add up to 1, even if all the individual class probabilities are small. E.g. model output = [0.1, 0.05, 0.05] you can assume that it is the other class because of low probs. If you take softmax, this turns into output=[0.4, 0.2, 0.2] then the 0.4 seems high, so do not do this. $\endgroup$ Oct 27, 2020 at 9:44
  • $\begingroup$ Yes that's true, in this case could I use sigmoid instead ? $\endgroup$ Oct 27, 2020 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.