Package: zamba
zamba - a command line interface for species classificationHOMEPAGEDOCUMENTATIONZamba means "forest" in the Lingala language.Zamba is a command-line tool built in Python to automatically identify the species seen in camera trap videos from sites in central Africa. The tool makes predictions for 24 common species in these videos. For more information, see the documentation.Thezambacommand will be the entry point for users (see example usage below).Prerequisites (for more detail, seethe documentation)Python3.6ffmpeg, codecs for handling the video loadingInstallingzamba(for more detail, seethe documentation)GPU or CPUzambais significantly faster when using a machine with a GPU instead of just a CPU. To use a GPU, you must be using annvidia gpu,installed and configured CUDA, andinstalled and configured CuDNNper their specifications. Once this is done, you can select to install the version of zamaba that usestensorflowcompiled for GPU.When a user installszambathat user must specify to install the GPU or CPU version. If the user fails to make this specification,no version of tensorflow will be installed, thus everything will fail.To install withtensorflow cpu(you do not have a GPU)$ pip install zamba[cpu]To install withtensorflow gpu$ pip install zamba[gpu]Example usageOnce zamba is installed, you can see the commands withzamba:zambaUsage: zamba [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  predict  Identify species in a video.
  train    [NOT IMPLEMENTED] Retrain network from...
  tune     [NOT IMPLEMENTED] Update network with new...And you can see the options you can pass to thepredictcommand with:zamba predict --helpUsage: zamba predict [OPTIONS] [DATA_PATH] [PRED_PATH]

  Identify species in a video.

  This is a command line interface for prediction on camera trap footage.
  Given a path to camera trap footage, the predict function use a deep
  learning model to predict the presence or absense of a variety of species
  of common interest to wildlife researchers working with camera trap data.

Options:
  --tempdir PATH                 Path to temporary directory. If not
                                 specified, OS temporary directory is used.
  --proba_threshold FLOAT        Probability threshold for classification. if
                                 specified binary predictions are returned
                                 with 1 being greater than the threshold, 0
                                 being less than or equal to. If not
                                 specified, probabilities between 0 and 1 are
                                 returned.
  --output_class_names           If True, we just return a video and the name
                                 of the most likely class. If False, we return
                                 a probability or indicator (depending on
                                 --proba_threshold) for every possible class.
  --model_profile TEXT           Defaults to 'full' which is slow and
                                 accurate; can be 'fast' which is faster and
                                 less accurate.
  --weight_download_region TEXT  Defaults to 'us', can also be 'eu' or 'asia'.
                                 Region for server to download weights.
  --verbose                      Displays additional logging information
                                 during processing.
  --help                         Show this message and exit.Oncezambais installed, you can execute it on any directory of video files. The tool does not recursively search directories, so all of the files must be at the top level of the directory. The algorithm will work the best with 15 second videos since that is what it is trained on, though it will sample frames from longer videos, which may be less reliable.NOTE:zambaneeds to download the "weights" files for the neural networks that it uses to make predictions. On first run it will download ~1GB of files with these weights.Once these are downloaded, the tool will use the local versions and will not need to perform this download again.zamba predict path/to/videosBy default the output will be written to the fileoutput.csvin the current directory. If the file exists, it will be overwritten.Running thezambatest suiteThe includedMakefilecontains code that uses pytest to run all tests inzamba/tests.The command is (from the project root),$ make testTesting End-To-End Prediction Withtest_cnnensemble.pyThe testtests/test_cnnensemble.pyruns an end-to-end prediction withCnnEnsemble.predict(data_dir)using a video that automatically gets downloaded along with theinputdirectory (this and all required directories are downloaded upon instantiation ofCnnEnsembleif they are not already present in the project).By default this test is skipped due to thepytestdecorator@pytest.mark.skip(reason="This test takes hours to run, makes network calls, and is really for local dev only.")
def test_predict():
    data_dir = Path(__file__).parent.parent / "models" / "cnnensemble" / "input" / "raw_test"

    manager = ModelManager('', model_class='cnnensemble', proba_threshold=0.5)
    manager.predict(data_dir, save=True)It is reccomended that thedecorator be commented out in order to test end-to-end prediction locally. However, this change should never be pushed, as the lightweight machines on codeship will not be happy, or able, to complete the end-to-end prediction.To test end-to-end prediction usingmake teston a different set of videos, simply editdata_dir.