Detector
- class byotrack.api.detector.Detector
Bases:
ABCBase class for detections in videos.
Detect on each frame the objects of interest.
- abstractmethod run(video: Sequence[np.ndarray] | np.ndarray) Sequence[byotrack.Detections]
Run the detector on a whole video.
- Parameters:
video (Sequence[np.ndarray] | np.ndarray) – Sequence of T frames (array). Each array is expected to have a shape ([D, ]H, W, C)
- Returns:
Detections for each frame (ordered by frames)
- Return type:
Sequence[byotrack.Detections]
- class byotrack.api.detector.BatchDetector(batch_size: int = 20)
Bases:
DetectorAbstract detector that performs detection directly by batch.
Usually leads to faster implementation of the detection process when batch size is greater than 1.
- run(video: Sequence[np.ndarray] | np.ndarray) list[byotrack.Detections]
Run the detector on a whole video.
- Parameters:
video (Sequence[np.ndarray] | np.ndarray) – Sequence of T frames (array). Each array is expected to have a shape ([D, ]H, W, C)
- Returns:
Detections for each frame (ordered by frames)
- Return type:
Sequence[byotrack.Detections]
- abstractmethod detect(batch: np.ndarray) Sequence[byotrack.Detections]
Apply the detection on a batch of frames.
- Parameters:
batch (np.ndarray) – Batch of video frames Shape: (B, [D, ]H, W, C)
- Returns:
Detections for each given frame
- Return type:
Sequence[byotrack.Detections]
- class byotrack.api.detector.DetectionsRefiner
Bases:
ABCAbstract class for method to improve a coarse detection result.
This assumes the refining can be done independently for each frame.
Warning: The class is still experimental and may change in future versions
- abstractmethod apply(detections: Detections | ndarray | Tensor, frame: ndarray | None = None) Detections
Refines Detections of the given frame.
- Parameters:
detections (byotrack.DetectionsLike) – Detections to refine
frame (np.ndarray | None) – The associated frame of the video (optional) Shape: ([D, ]H, W, C) Default: None
- Returns:
Refined detections
- Return type:
byotrack.Detections
- run(detections_sequence: Sequence[byotrack.DetectionsLike], video: Sequence[np.ndarray] | np.ndarray | None = None) list[byotrack.Detections]
Run the refiner on a full video / detections sequence.
- Parameters:
detections_sequence (Sequence[byotrack.DetectionsLike]) – Sequence of T detections to refine
video (Sequence[np.ndarray] | np.ndarray | None) – Optional corresponding sequence of T frames. Each frame is expected to have a shape ([D, ]H, W, C)
- Returns:
Sequence of the T refined detections
- Return type:
Sequence[byotrack.Detections]
- class byotrack.api.detector.GroundTruthDetector(segmentations: Sequence[np.ndarray] | np.ndarray | None = None, batch_size=1)
Bases:
BatchDetectorConvert a video of segmentations into Detections using the BatchDetector API.
Each frame in the video is expected to be an instance segmentation mask of shape ([D, ]H, W, 1) The video should not be normalized and each pixel is expected to be an integer.
- Note: The segmented video can be given at construction time of the detector. In such case,
this video will be used over the one given in run. This allows to use precomputed detections as well as the original video in a [Batch]MultiStepTracker pipeline.
Example:
### Example: Loading CTC segmentation video = byotrack.Video("dataset/01_ERR_SEG") # Load segmentation for CLB # video = byotrack.Video("dataset/01_GT/SEG") # Load ground-truth segmentation # video = byotrack.Video("dataset/01_RES/TRA") # Load predicted tracks segmentation detector = GroundTruthDetector() detections_sequence = detector.run(video) ### Example: Loading precomputed segmentations segmentations = byotrack.Video("segmentations.tiff") # Shape (T, [D, ]H, W, 1), dtype: int detections_sequence = GroundTruthDetector().run(segmentations) ### Example: Tracking with precomputed segmentations with online loading video = byotrack.Video("video.tiff").normalize() # Shape (T, [D, ]H, W, 1), dtype: float segmentations = byotrack.Video("segmentations.tiff") # Shape (T, [D, ]H, W, 1), dtype: int detector = GroundTruthDetector(segmentations) linker = ... tracker = BatchMultiStepTracker(detector, linker) # This will forward the segmented frame to the Detector, # but the video frame to the linker. tracks = tracker.run(video)
- run(video: Sequence[np.ndarray] | np.ndarray) list[byotrack.Detections]
Run the detector on a whole video.
- Parameters:
video (Sequence[np.ndarray] | np.ndarray) – Sequence of T frames (array). Each array is expected to have a shape ([D, ]H, W, C)
- Returns:
Detections for each frame (ordered by frames)
- Return type:
Sequence[byotrack.Detections]
- detect(batch: ndarray) list[SegmentationDetections]
Apply the detection on a batch of frames.
- Parameters:
batch (np.ndarray) – Batch of video frames Shape: (B, [D, ]H, W, C)
- Returns:
Detections for each given frame
- Return type:
Sequence[byotrack.Detections]