Skip to content

missingbytes-cp/classifier-pipeline

 
 

Repository files navigation

Please note

We are in the process of changing how we classify videos. We are moving away from video based tagging, to tagging parts of the videos where we have recognised there may be an animal. These consist of smaller rectangles of video that are linked together through frames and we call them tracks.

As part of this change, the projects extract.py and classify.py has been updated to use our new python package structure and config files but the rest of the projects have not. At this stage we are not sure whether build.py, train.py and evaluate.py run as we are still refactoring them. (Please use code commited last year (2018) if you want to run these scripts)

Overview

These scripts handle the data pre-processing, training, and execution of a Convolutional Neural Network based classifier for thermal vision.

The output is a TensorFlow model that can identify 48x48 video clips centered on the object of interest.

Scripts

extract.py

Processes tagged CPTV files extracting targets of interest into track files used for training.

build.py

Builds a data set from extracted track files.

train.py

Trains a neural net using a provided test / train / validation dataset.

classify.py

Uses a pre-trained model to identifying and classifying any animals in a CPTV file.

evaluate.py

Evaluates the performance of a classify.py run and generates reports.

Setup

  1. Create a virtual environment and install the necessary prerequisites
    pip install -r requirements.txt

  2. Copy the classifier_Template.yaml to classifier.yaml and then edit this file with your own settings. You will need to set up the paths for it work on your system. (Note: Currently these settings only apply to classify.py and extract.py)

  3. Optionally install GPU support for tensorflow (note this requires additional setup)
    pip install tensorflow-gpu

  4. MPEG4 output requires FFMPEG to be installed which can be found here. On windows the installation path will need to be added to the system path.

Usage

Downloading the Dataset

CPTV files can be downloaded using the cptv-downloader tool.

Training the Model

First download the CPTV files by running

python cptv-download.py --user x --password x

Next extract the track files. This can take some time

python extract.py all -v -p

Now we can build the data set

python build.py data

And finally train the model

python train.py -dataset=data -model-name=model --epochs=10

Classifying animals within a CPTV File

A pre-trained model can be used to classify objects within a CPTV video

python classify.py [cptv filename] -p

This will generate a text file listing the animals identified, and create an MPEG preview file.

Release and Update

  1. Create a release on GitHub (https://github.com/TheCacophonyProject/Project-Overview/wiki/Releases)

  2. SSH into server

  3. wget latest installer from GitHub

    wget https://github.com/TheCacophonyProject/classifier-pipeline/releases/download/vx.x.x/classifier-pipeline_x.x.x_amd64.deb

  4. Install downloaded deb

    sudo apt install ./classifier-pipeline_x.x.x_amd64.deb

  5. Make changes to config file if needed

    /etc/cacophony/classifier.yaml

  6. Restart service

    systemctl restart cacophony-processing.thermal@xx.service

  7. View logs

    journalctl -u cacophony-processing.thermal@xx.service -f

About

Exports tracked animals through thermal vision.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.8%
  • Shell 0.2%