I want to train CNN using keras to detect a single object - "cars". Do I need to train CNN using cars' images only or need to train it using negative images (no cars) as well?
2 Answers
You need training samples with cars and no cars. If you intend to give it an image and detect the car, it needs to sweep through and classify car or no car for each segment of the image. Hence, it needs to know what a non car looks like.
As a negative example, though, you could just include segments of an image that don't include the car. So technically you could train only on images with pictures of cars, as long as you classify each region.
Alternatively, you could solve the problem "is there a car in this image" in which case you would need full images without cars as well as with cars.
You cannot construct a loss function as far as I know* without negative and positive examples.
*probably this is being worked on.
Also it may be a good idea to have the same number of negative as positive training examples, also mix them up randomly.