tools package

tools.generate_detections module

class tools.generate_detections.ImageEncoder(checkpoint_filename, input_name='images', output_name='features')

Bases: object

tools.generate_detections.create_box_encoder(model_filename, input_name='images', output_name='features', batch_size=32)

Create the bounding box encoder

Parameters
  • model_filename (str) – The filename for the model

  • input_name (str) – The input name. Default = “images”

  • output_name (str) – The output name. Default = “features”

  • batch_size (int) – The Batch size for the encoder. Default = 32

Returns

The function encoder is run and returned

Return type

function

tools.generate_detections.extract_image_patch(image, bbox, patch_shape)

Extract image patch from bounding box.

Parameters
  • image (ndarray) – The full image.

  • bbox (array_like) – The bounding box in format (x, y, width, height).

  • patch_shape (Optional[array_like]) – This parameter can be used to enforce a desired patch shape (height, width). First, the bbox is adapted to the aspect ratio of the patch shape, then it is clipped at the image boundaries. If None, the shape is computed from bbox.

Returns

An image patch showing the bbox, optionally reshaped to patch_shape. Returns None if the bounding box is empty or fully outside of the image boundaries.

Return type

ndarray | NoneType

tools.generate_detections.generate_detections(encoder, mot_dir, output_dir, detection_dir=None)

Generate detections with features.

Parameters
  • encoder (Callable[image, ndarray] -> ndarray) – The encoder function takes as input a BGR color image and a matrix of bounding boxes in format (x, y, w, h) and returns a matrix of corresponding feature vectors.

  • mot_dir (str) – Path to the MOTChallenge directory (can be either train or test).

  • output_dir – Path to the output directory. Will be created if it does not exist.

  • detection_dir – Path to custom detections. The directory structure should be the default MOTChallenge structure: [sequence]/det/det.txt. If None, uses the standard MOTChallenge detections.

tools.generate_detections.main()

Main function that calls: parse_args() create_box_encoder generate_detections

tools.generate_detections.parse_args()

Parse command line arguments.

tools.freeze_model module

tools.freeze_model.create_inner_block(incoming, scope, nonlinearity=None, weights_initializer=None, bias_initializer=None, regularizer=None, increase_dim=False, summarize_activations=True)
tools.freeze_model.main()
tools.freeze_model.parse_args()

Parse command line arguments.

tools.freeze_model.residual_block(incoming, scope, nonlinearity=<function elu>, weights_initializer=None, bias_initializer=None, regularizer=None, increase_dim=False, is_first=False, summarize_activations=True)