I am trying to detect if an image contains human or not. I will use CNN for this. I am planning to make a dataset like following.

     human (contains 2000 or more human image)
     other object (contains 2000 or more non human image)

     human (contains 500)
     other object (contains 500 )

I am planning to use keras and I will train data from directory .

Is there any alternative approach ? Because I am having trouble with collecting human and non human object image.


I had a similar problem with skin disease classification. You can see the question and its answers too here. Gathering a dataset of human pictures could be easy but that of non-human could be nearly impossible ( non-human objects are a huge set of objects )


We can use a Siamese Convolutional Neural Network. I have written a blog on it. See here. They perform one-shot learning and are best when we have smaller datasets.

A standard CNN tries to classify whether the pictures belongs to any one of the classes -> (HUMAN, NON_HUMAN ). The Siamese CNN outputs a similarity score rather than class probabilities. A standard CNN learns to classify and on the other hand, a Siamese CNN learns to differentiate images.

How does it work? ( In the context of your task )

Suppose I have an input image $x$. This is our input for the Siamese CNN. I have two more images, say $f$ and $g$. Image $f$ belongs to class 1 ( HUMAN ) whereas $g$ belongs to CLASS 2 ( NON-HUMAN ). The Siamese CNN takes in 2 images as input and outputs how similar they are.

$ Siamese( x , f ) = 0.678$

$ Siamese( x , g ) = 0.987$

$Clearly, \space Siamese( x , f ) < Siamese( x , g )$

Therefore, the image belongs to CLASS 2. You can find its other advantages on the blog. Hope this helps.


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