crowsetta.Annotation#
- class crowsetta.Annotation(annot_path: str | bytes | PathLike | Path, notated_path: str | bytes | PathLike | Path | None = None, seq: Sequence | list[Sequence] | None = None, bboxes: list[BBox] | None = None)[source]#
Bases:
object
A class to represent annotations for a single file.
The annotations can be one of two types: a single sequence, or a list of bounding boxes.
- annot_path#
Path to file from which annotations were loaded.
- Type:
- notated_path#
Path to file that
annot_path
annotates. E.g., an audio file, or an array file that contains a spectrogram generated from audio. Optional, default is None.- Type:
- seq#
A
crowsetta.Sequence
instance, or a list ofcrowsetta.Sequence
instances. Eachcrowsetta.Sequence
instance represents a sequence of annotated segments, with a segment having an onset time, offset time, and label.- Type:
- bboxes#
List of annotated bounding boxes, each having an onset time, offset time, lowest frequency, highest frequency, and label. Each item in the list will be a
crowsetta.BBox
instance.- Type:
Notes
A
crowsetta.Annotation
can have either aseq
attribute or abboxes
attribute, but not both.Examples
A toy example of a sequence-like annotation.
>>> import numpy as np >>> import crowsetta >>> onsets_s = np.array([1.0, 3.0, 5.0]) >>> offsets_s = np.array([2.0, 4.0, 6.0]) >>> labels = np.array(['a', 'a', 'b']) >>> seq = crowsetta.Sequence.from_keyword(labels=labels, onsets_s=onsets_s, offsets_s=offsets_s) >>> annot = crowsetta.Annotation(notated_path='bird1.wav', annot_path='bird1.csv', seq=seq) >>> print(annot) Annotation(annot_path=PosixPath('bird1.csv'), notated_path=PosixPath('bird1.wav'), seq=<Sequence with 3 segments>)
A toy example of a bounding box-like annotation.
>>> bbox1 = crowsetta.BBox(label='Pinacosaurus grangeri', onset=1.0, offset=2.0, low_freq=3e3, high_freq=1e4) >>> bbox2 = crowsetta.BBox(label='Pinacosaurus grangeri', onset=3.0, offset=4.0, low_freq=3.25e3, high_freq=1.25e4) >>> bboxes = [bbox1, bbox2] >>> annot = crowsetta.Annotation(notated_path='prebird1.wav', annot_path='prebird1.csv', bboxes=bboxes) >>> print(annot) Annotation(annot_path=PosixPath('prebird1.csv'), notated_path=PosixPath('prebird1.wav'), bboxes=[BBox(onset=1.0, offset=2.0, low_freq=3000.0, high_freq=10000.0, label='Pinacosaurus grangeri'), BBox(onset=3.0, offset=4.0, low_freq=3250.0, high_freq=12500.0, label='Pinacosaurus grangeri')])
- __init__(annot_path: str | bytes | PathLike | Path, notated_path: str | bytes | PathLike | Path | None = None, seq: Sequence | list[Sequence] | None = None, bboxes: list[BBox] | None = None)[source]#
Methods
__init__
(annot_path[, notated_path, seq, bboxes])