-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- add `interface` sub-pacakge with base.py + defines `BaseFormat` - add seq sub-package in `interface` with base.py + defines `SeqLike` interface - add bbox sub-package in `interface` with base.py + definfes `BBoxLike` interface - import BaseFormat and sub-packages in interface/__init__.py - import inside __init__ in Transcriber to avoid circular imports
- Loading branch information
1 parent
6a839f8
commit 7c495c2
Showing
10 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .base import BaseFormat | ||
from .bbox import BBoxLike | ||
from .seq import SeqLike |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import abc | ||
|
||
|
||
class BaseFormat(abc.ABC): | ||
"""abstract base class | ||
that declares the interface | ||
for any sub-class that | ||
represents annotations | ||
loaded from a file | ||
in a specific format | ||
for annotating vocalizations. | ||
""" | ||
@classmethod | ||
@abc.abstractmethod | ||
def from_file(cls) -> 'Self': | ||
"""loads an annotation from a file | ||
in a given format. | ||
""" | ||
... | ||
|
||
def to_annot(self) -> 'Union[crowsetta.Annotation,List[crowsetta.Annotation]]': | ||
"""converts the instance representing annotations | ||
loaded from a file into a `crowsetta.Annotation` | ||
or a list of `crowsetta.Annotation`s, | ||
that can be used to convert to other formats | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .base import BBoxLike |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import abc | ||
|
||
from ..base import BaseFormat | ||
|
||
|
||
class BBoxLike(BaseFormat, abc.ABC): | ||
"""abstract base class defining the interface | ||
for any annotation format | ||
that can be represented as a set of bounding boxes, | ||
where each bounding box has corners | ||
((x_min, y_max), (x_min, y_min), (x_max, y_max), (x_max, y_min)) | ||
and a label. | ||
""" | ||
def to_bbox(self) -> 'Union[crowsetta.BBox, Sequence[crowsetta.BBox]]': | ||
"""converts the annotation to | ||
a ``crowsetta.BBox`` instance | ||
or a python set of | ||
``crowsetta.BBox`` instances. | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .base import SeqLike |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import abc | ||
|
||
from ..base import BaseFormat | ||
|
||
|
||
class SeqLike(BaseFormat, abc.ABC): | ||
"""abstract base class defining the interface | ||
for any annotation format | ||
that can be represented as a sequence of segments, | ||
with each segment having an onset time, | ||
offset time, and a label. | ||
""" | ||
def to_seq(self) -> 'Union[crowsetta.Sequence, Sequence[crowsetta.Sequence]]': | ||
"""converts the annotation to | ||
a ``crowsetta.Sequence`` instance | ||
or a python sequence of | ||
``crowsetta.Sequence``s | ||
(e.g., a list or tuple). | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters