1
$\begingroup$

I am developing an image classifier using opencv,python.I am using svm from opencv. The image classifier classifies Animals,vehicles and Humans.It works fine.But when i give the image of 'nature scene' then also it will classify.That's the problem.How can i output it as unclassified.When i give the input a image thats not belonging to the trained class How can i output it as unclassified.? Just for reference my code to predict is

result = svm.predict(testData)
if result==1:
 print 'Vehicle'
elif result==2:
 print 'Animal'
elif result==3:
 print 'Humans'
$\endgroup$
1
$\begingroup$

Well, short answer is "you can't".
SVMs have been trained for separating 3 classes and they will always work for such three classes.
The best thing to do is to enlarge your training set with

  • vehicle images
  • animals images
  • humans images
  • images that are not vehicle AND not animals AND not humans

Such fourth class will be your "unclassified" label.

I'm not an expert on OpenCV SVM, but there's another thing you can try.
In SVMs every prediction is mapped with a decision value (or probability value), if you can evaluate (or gather from the toolbox) such decision value you can set a threshold on such predictions.
Something like: I classify a given image and each SVM returns its prediction along with the probability value. If such probability values are below a given threshold it means that the SVMs are really not that confident about their prediction and you can easily mark such image as "unclassified". You should, however, pick up a good value for such threshold, that's a non-trivial task.

$\endgroup$
1
  • $\begingroup$ I created an unclassified class just like another classes.It worked fine. $\endgroup$
    – Ceem
    Apr 10 '16 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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