title: How can I build a single machine learning model, than can classify an image and then draw bounding boxes around all the labels inside that image?
body: <p>Suppose I have a dataset with images of cats, dogs, giraffes, lions, crocodiles and other animals(here they are the labels). Consider I have in total <code>n</code> labels. A single image may contain one or more animals of a single type. That is, an image of the lion may contain multiple lions in it, but no other labels(animals).</p>
  <p>I have to make an ML model, that first classifies an image into a particular label, and then uses object detection, to draw bounding boxes around all the particular animal(or label) in that image.</p>
  <p>How can I achieve this by using minimal ML model files(like .h5 or .pth files)?</p>
  <p>An obvious brute force approach would be to build a classifier model, that can classify an image into its particular label and then build object detection models for the <code>n</code> labels(here animals) and use the appropriate model to get bounding boxes. But this would result in a total of <code>n+1</code> ML models, and I don't want this to happen. I would like to have minimal ML models and get the task done.</p>
  <p>Is it possible to do this with just two ML models or just one?
  How can I effectively crack this problem?</p>
  <p>Edit: My primary aim is to use the information, I get from the classifier model, in object detection to improve its accuracy.</p>
  <p>Suppose my classifier identified the image as a lion, Then I want the model, that's trained to identify the bounding box of a lion to be employed to find the bounding boxes in the image, than a multi-class object detection model which is trained on all labels(here animals).</p>
  <p>I wish to do this because, in my use case, the labels are similar and a multi-class image detection model may have reduced accuracy.</p>