discopat package

Subpackages

Submodules

discopat.basics module

discopat.basics.gs_to_rgb(array, channel_mode='channels_last')[source]
Parameters:
  • array (ndarray)

  • channel_mode (str)

Return type:

ndarray

discopat.basics.to_01(array, eps=1e-10)[source]
Parameters:
  • array (ndarray)

  • eps (float)

Return type:

ndarray

discopat.basics.to_int(array)[source]
Parameters:

array (ndarray)

Return type:

ndarray

discopat.disco module

discopat.disco.main()[source]

discopat.display module

discopat.display.frame_to_pil(frame, tracks, max_track_length=0, persistence=10, cmap='gray', track_color='red')[source]

Make a PIL image from a frame.

Parameters:
  • frame (Frame)

  • tracks (np.array)

  • max_track_length (int)

  • persistence (int)

  • cmap (str)

  • track_color (str)

Return type:

Image

discopat.display.get_center_path(track)[source]

Get the trajectory of the center of the boxes corresponding to one track.

Parameters:

track (array) – Array of shape (num_frames, 5) where each line corresponds to a box: - track[:, 0] = id of the frame, - track[:, 1] = xmin, - track[:, 2] = ymin, - track[:, 3] = xmax, - track[:, 4] = ymax.

Returns:

Array of shape (num_frame, 2), where each line corresponds to the (x, y) coordinates of the center of the box.

Return type:

array

discopat.display.make_movie(movie, persistence, cmap, track_color, fps, output_format)[source]
Parameters:
  • movie (Movie)

  • persistence (int)

  • cmap (str)

  • track_color (str)

  • fps (int)

  • output_format (str)

discopat.display.plot_annotation(ax, annotation, color)[source]
Parameters:
discopat.display.plot_box(ax, box, color)[source]
Parameters:
  • ax (Axes)

  • box (Box)

  • color (str)

discopat.display.plot_frame(frame, cmap='gray', annotation_color='tab:red', show_figure=True, return_figure=False, figure_size=None, figure_dpi=None)[source]
Parameters:
  • frame (Frame)

  • cmap (str)

  • annotation_color (str)

  • show_figure (bool)

  • return_figure (bool)

  • figure_size (tuple[float, float] or None)

  • figure_dpi (int or None)

discopat.display.plot_keypoint(ax, keypoint, color)[source]
Parameters:
  • ax (Axes)

  • keypoint (Keypoint)

  • color (str)

discopat.display.to_int(image_array, eps=1e-10)[source]

Convert array to int [0, 255].

Warning: values will be scaled even if the input array is already of type int.

Parameters:
  • image_array (array)

  • eps (float)

Return type:

array

discopat.tokam module

discopat.tokam.collate_fn(batch)[source]

Collate function to make dataloaders.

Parameters:

batch (Tensor)

Return type:

tuple

discopat.tokam.load_model(model_name)[source]
Parameters:

model_name (str)

Return type:

Model

discopat.tokam.load_movie(movie_name)[source]
Parameters:

movie_name (str)

Return type:

Movie

discopat.tokam.load_set(set_name)[source]
Parameters:

set_name (str)

Return type:

Movie

discopat.tokam.make_dataloaders(train_frames, val_frames, label_map, train_batch_size, val_batch_size)[source]

Build data loaders from train- and val frames.

Parameters:
  • train_frames (list[Frame])

  • val_frames (list[Frame])

  • label_map (dict[int, str])

  • train_batch_size (int)

  • val_batch_size (int)

Return type:

tuple[DataLoader, DataLoader]

discopat.tracking module

SORT: A Simple, Online and Realtime Tracker.

Copyright (C) 2016-2020 Alex Bewley alex@bewley.ai

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class discopat.tracking.KalmanBoxTracker(bbox)[source]

Bases: object

This class represents the internal state of individual tracked objects observed as bbox.

count = 0
get_state()[source]

Returns the current bounding box estimate.

predict()[source]

Advances the state vector and returns the predicted bounding box estimate.

update(bbox)[source]

Updates the state vector with observed bbox.

class discopat.tracking.Sort(max_age=1, min_hits=3, iou_threshold=0.3)[source]

Bases: object

update(dets=array([], shape=(0, 5), dtype=float64))[source]
Params:

dets - a numpy array of detections in the format [[x1,y1,x2,y2,score],[x1,y1,x2,y2,score],…]

Requires: this method must be called once for each frame even with empty detections (use np.empty((0, 5)) for frames without detections). Returns the a similar array, where the last column is the object ID.

NOTE: The number of objects returned may differ from the number of detections provided.

discopat.tracking.associate_detections_to_trackers(detections, trackers, iou_threshold=0.3)[source]

Assign detections to tracked object (both represented as bounding boxes).

Returns 3 lists of matches, unmatched_detections and unmatched_trackers

discopat.tracking.convert_bbox_to_z(bbox)[source]
Takes a bounding box in the form [x1,y1,x2,y2] and returns z in the form

[x,y,s,r] where x,y is the centre of the box and s is the scale/area and r is the aspect ratio

discopat.tracking.convert_x_to_bbox(x, score=None)[source]
Takes a bounding box in the centre form [x,y,s,r] and returns it in the form

[x1,y1,x2,y2] where x1,y1 is the top left and x2,y2 is the bottom right

discopat.tracking.iou_batch(bb_test, bb_gt)[source]

From SORT: Computes IOU between two bboxes in the form [x1,y1,x2,y2].

discopat.tracking.linear_assignment(cost_matrix)[source]
discopat.tracking.parse_args()[source]

Parse input arguments.

discopat.utils module

discopat.utils.get_device(allow_mps=True)[source]
Parameters:

allow_mps (bool)

Module contents