In the previous chapters we saw how we can work with pretrained classifiers to detect images and learn new categories. In all those experiments, though, we always assumed there was only one thing to see in our images. In the real world this is not always the case—we might have an image with both a cat and a dog, for example.
This chapter explores some techniques to overcome this limitation. We start out with building on a pretrained classifier and modifying the setup in such a way that we get multiple answers. We then look at a state-of-the art solution to solving this problem.
This is an area of active research, and the most advanced algorithms are tricky to reproduce inside a Python notebook on top of Keras. Instead, we use an open source library in the second and third recipes of this chapter to demonstrate what is possible.
The code for this chapter can be found in the following notebook:
11.1 Detecting Multiple Images
How do you find multiple image classes in a single image?
Use the outputs of the middle layers as a feature map and run a sliding window over them.
Using a pretrained neural network to do image classifying is not very difficult once we have everything set up. If there are multiple objects to detect in the image, we don’t do so well though: the pretrained network will return the likelihood that the image represents any of the classes. If it ...