I'm pretty new to ML so I apologize for the potentially trivial question; I've been unable to find a clear answer to my question.

Let's imagine that I want to build a model that is able to detect sharks in images. I put a camera in the water and hit record. I end up with thousands of images. Some of the frames depict a single shark, some depict several sharks, others depict 1 or more sharks among other objects such as fish and maybe even a random submarine.

Now, the question is: which of the images are most suitable, which should I throw away, and why?

For instance, must each individual training image contain ONE and ONLY ONE shark (each at slightly different angles, lighting, etc.)? Is an image/frame depicting several sharks OK (I imagine that would work for image classification, but not so well for object detection)? What about images that contain sharks and other objects/fish?

If someone can explain to me (even better if you have a link to a good resource), I would really appreciate it.


1 Answer 1


It depends on what you are building. For classification tasks, you want 1 object to exist, and to take up nearly the entire frame. For object detection tasks, either will work. Classification CNN works differently than Object Detection.

In a classification CNN, the CNN learns features and then there is a head which does the classification. A classification CNN does not tell you the location of the object because the object is the image. A classification CNN only tells you the object, which is why it doesn't make any sense to include multiple objects in the image. Only include the bounding box of 1 instance of the object.

In an object detection CNN, the CNN learns a location and a classification ID of an object. So here either multiple instances or single instances are useful to train the CNN.

One book that helped me a lot with understanding this is Advanced Deep Learning with TensorFlow 2 and Keras, Chapter 11.


What is a "head" in "the CNN learns features and there is a head that does the classification"?

There are 2 types of layers in a CNN: (1) convolutional layers and (2) fully-connected layers. Convolutional layers are used to extract features. Fully connected layers correlate features to an image classification.

  • $\begingroup$ Thanks for the help! Can you please clarify for me, what do you mean by head in "the CNN learns features and then there is a head which does the classification"? $\endgroup$
    – pookie
    Sep 28, 2022 at 1:34

Your Answer

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

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