agentmorris / MegaDetector

MegaDetector is an AI model that helps conservation folks spend less time doing boring things with camera trap images.
MIT License
117 stars 26 forks source link

Batch inference with classifier? #28

Closed agentmorris closed 1 year ago

agentmorris commented 1 year ago

What is the appropriate way to do batch inference using a trained classifier? The classifier documentation lists three methods:

  1. predict_image.py
  2. detect_and_predict_image.py
  3. generate_sample_predictions.py

The first appears not to support batch inference. #2 and #3 do batch inference, but running each of them resulted in the entire data set attempting to be loaded into memory. What is the correct way to perform inference on a large number of images using this repo?


Issue cloned from Microsoft/CameraTraps, original issue posted by davidwhealey on Apr 27, 2020.

agentmorris commented 1 year ago

Wow, we really worked hard to hide the script that I would actually recommend using in this case, which is none of those three... :)

If you are planning to run both our detector and a classifier trained with our recommended pipeline, I would do this in two stages, with:

The reason you didn't see the latter script before is that it was all by itself in a folder called "api", I just moved it out of that folder.

This two-step process is exactly what we did, for example, to generate these results;

Let us know if that helps!

-Dan


(Comment originally posted by agentmorris)