Script to classify images of plants and animals with the image-based species recognition models provided by Microsoft AI for Earth. The code was extracted from this Microsoft repository, which can also be used for the inference on its own by following the described steps there, but it contains some more scripts which were not necessary for us and thus removed in this repository. The model is not updated anymore.
-
Install conda / miniconda if you do not have already (see here for installation of miniconda and here for a conda cheatsheet).
-
Create a conda environment from the
environment.yml
file by executing
conda env create -f environment.yml
- Clone this repository by
git clone https://github.com/EibSReM/MicrosoftSpeciesClassification.git
and change to respective directory (cd MicrosoftSpeciesClassification
)
-
If you want to download the pretrained pytorch model manually you can do so here (409 MB). This is not mandatory since the script also offers the opportunity to download the model automatically.
-
The same for the taxononmy file that you can download manually here
-
Adapt api_root in the
classify_images.py
script. It should be the path to the cloned repository. -
Adapt the paths to the pytorch model, the taxonomy file and the images (folder) in the
classify_images.py
script (if you don't want to download the model and taxonomy files beforehand the script can do it for you, if you change the paths to the given hyperlinks) -
Run script
python classify_images.py
- Find results in
classification_output.csv
Classifying 204 images, the script run 2175 seconds (~ 36 minutes) on a Windows 10 notebook with the following hardware specifications:
- Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz 1.99 GHz
- 20 GB Ram