Skip to content

Latest commit

 

History

History
147 lines (103 loc) · 5.54 KB

File metadata and controls

147 lines (103 loc) · 5.54 KB

Overview

Most of the scripts in this folder create or manipulate COCO Camera Traps databases, i.e. .json files in the COCO Camera Traps format.

Contents

Scripts in this folder

annotations

The only file in this folder is annotation_constants.py, which defines a set of shared constants mapping class IDs to categories.

databases

Miscellaneous tools for manipulating COCO Camera Traps .json files. Of particular note is integrity_check_json_db.py, which validates that a CCT database is well-formatted, optionally checking image existence and size.

lila

Scripts for preparing data for upload to LILA, and working with LILA index files.

importers

Code for converting frequently-used metadata formats (or sometimes one-off data sets) to COCO Camera Traps .json files.

COCO Camera Traps format

Permanent link to this section: https://lila.science/coco-camera-traps

The COCO Camera Traps (CCT) format (used for camera trap data on LILA) and for some intermediate processing by other scripts in this repo is an extension of the COCO format to add fields that are relevant for camera trap data. CCT is a superset of COCO, so CCT datasets are compatible with tools that expect COCO-formatted data.

{
  "info" : info,
  "images" : [image],
  "categories" : [category],
  "annotations" : [annotation]
}

info 
{
  ## Required ##

  "version" : str,
  "description" : str,
  
  ## Optional ##

  "year" : int,
  "contributor" : str
  "date_created" : datetime
}

image
{
  ## Required ##

  "id" : str,
  "file_name" : str,
  
  ## Optional ##

  "width" : int,
  "height" : int,
  "rights_holder" : str,    

  # Precise date formats have varied a little across datasets, the spirit is
  # "any obvious format that dateutil knows how to parse".  Going forward,
  # we are using Python's standard string representation for datetimes, which
  # looks like: 
  #
  # 2022-12-31 09:52:50
  "datetime": datetime,  

  # A unique identifier for the sequence (aka burst, episode, or event) to 
  # which this image belongs
  "seq_id": str,

  # The total number of images in this event
  "seq_num_frames": int,

  # The zero-indexed index of this image within this event
  "frame_num": int
  
  # This is an int in older data sets, but convention is now strings
  "location": str,
  
  # Image corruption is quite common in camera trap images, and throwing out corrupt
  # images in database assembly is "dodging part of the problem".  Wherever possible,
  # use this flag to indicate that an image failed to load, e.g. in PIL and/or TensorFlow.
  "corrupt": bool
}

category
{
  ## Required ##
  
  # Category ID 0 reserved for the class "empty"; all other categories vary by data
  # set.  Non-negative integers only.
  "id" : int,

  # Can be any string, but if the category indicates empty, the standard is "empty"
  # (as opposed to "blank", "false trigger", "none", "misfire", etc.). 
  #
  # Lower-case names without spaces are encouraged, but not required.  I.e., all other
  # things being equal, use "gray_wolf" rather than "Gray Wolf".
  "name" : str  
}

annotation
{
  ## Required ##

  "id" : str,
  "image_id" : str,  
  "category_id" : int,
  
  ## Optional ##
  
  # These are in absolute, floating-point coordinates, with the origin at the upper-left
  "bbox": [x,y,width,height],
  
  # This indicates that this annotation is really applied at the *sequence* level,
  # and may not be reliable at the individual-image level.  Since the *sequences* are
  # the "atom of interest" for most ecology applications, this is common.
  "sequence_level_annotation" : bool
}

Note that the coordinates in the bbox field are absolute here, different from those in the MegaDetector results format, which are normalized.

Fields listed as "optional" are intended to standardize commonly-used parameters (such as date/time information). When present, fields should follow the above conventions. Additional fields may be present for specific data sets.

Gratuitous animal picture

pheasant in camera trap
Image credit Saola Working Group, from the SWG Camera Traps data set.