Skip to content
Switch branches/tags
This branch is 42 commits ahead of datitran/raccoon_dataset:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Object detection utility scripts

This repo contains a few Python scripts which may be useful for those trying to create the necessary prerequisite files to train an object detection model, either by using the TensorFlow Object Detection API or darknet.

Take a look inside the examples directory to have an idea of the types of files that these scripts expect as input/generate as output.


The repo provides a collection of scripts, which are to be called from the terminal. In order to know what arguments a particular script expects, run it with the -h flag to see a help message. For example: python -h. The output files generated by some scripts are used as input files for other scripts. Please take a look at the flowchart at the end of this page to understand in which order to use them.

  • reads the contents of image annotations stored in XML files, created with labelImg, and generates a single CSV file.
  • reads the CSV file and separates it into train and evaluation datasets, which are also CSV files. There are options to stratify by class and to select which fraction of the input CSV will be directed to the train dataset (the rest going to evaluation).
  • reads the previously generated CSV file (or any CSV file that has a column named "class") or a text file containing a single class name per line and no header, and generates a label map, one of the files needed to train a detection model using TensorFlow's Object Detection API.
  • reads the previously generated CSV and label map files, as well as all the images from a given directory, and generates a TFRecord file, which can then be used to train an object detection model with TensorFlow. The resulting TFRecord file is about the same size of all the original images that were included in it.
  • reads the CSV file and generates one .txt file for each image mentioned in the CSV file, whith the same name of the image file. These .txt files contain the object annotations for that image, in a format which darknet uses to train its models.

Script usage flowchart


Licenses are so complicated. This work began as a fork of Dat Tran's raccoon dataset repository, but then it became its own thing. Anyway, the license is unchanged and is in the repo.


No releases published


No packages published