-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added key filter transformer block, removed sleap dataset, added type…
… hinting
- Loading branch information
Showing
11 changed files
with
123 additions
and
63 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
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
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
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,38 @@ | ||
"""General purpose transformers for common pipeline processing tasks.""" | ||
from typing import Callable, Dict, List, Text | ||
|
||
from torch.utils.data.datapipes.datapipe import IterDataPipe | ||
|
||
|
||
class KeyFilter(IterDataPipe): | ||
"""Transformer for filtering example keys.""" | ||
|
||
def __init__(self, source_dp: IterDataPipe, keep_keys: List[Text] = None) -> None: | ||
"""Initialize KeyFilter with the source `DataPipe.""" | ||
self.dp = source_dp | ||
self.keep_keys = keep_keys | ||
|
||
def __iter__(self): | ||
"""Return a dictionary filtered for the relevant outputs. | ||
The input dictionary includes: | ||
- image: the full frame image | ||
- instances: all keypoints of all instances in the frame image | ||
- centroids: all centroids of all instances in the frame image | ||
- instance: the individual instance's keypoints | ||
- instance_bbox: the individual instance's bbox | ||
- instance_image: the individual instance's cropped image | ||
- confidence_maps: the individual instance's heatmap | ||
""" | ||
for example in self.dp: | ||
if self.keep_keys is None: | ||
# If keep_keys is not provided, yield the entire example. | ||
yield example | ||
else: | ||
# Filter the example dictionary based on keep_keys. | ||
filtered_example = { | ||
key: value | ||
for key, value in example.items() | ||
if key in self.keep_keys | ||
} | ||
yield filtered_example |
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
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
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
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
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
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
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