sleap.info.feature_suggestions#
Module for generating lists of frames using frame features, pca, kmeans, etc.
- class sleap.info.feature_suggestions.FrameGroupSet(method: str, item_group: Dict[FrameItem, int] = _Nothing.NOTHING, group_data: Dict[int, dict] = _Nothing.NOTHING, groupset_data: Dict = _Nothing.NOTHING)[source]#
Class for a set of groups of FrameItem objects.
Each item can have at most one group; each group is represented as an int.
- method#
Label for the method used to generate group set.
- Type:
str
- item_group#
Dictionary which maps each item to its group.
- Type:
Dict[sleap.info.feature_suggestions.FrameItem, int]
- group_data#
Dictionary of any extra data for each group; keys are group ids, values are dictionaries of data.
- Type:
Dict[int, dict]
- groupset_data#
Dictionary for any data about the entire set of groups.
- Type:
Dict
- property all_items#
Gets list of all items.
- extend_group_items(group: int, item_list: List[FrameItem])[source]#
Adds all items in list to group.
- property groups#
Iterate over groups, yielding group and list of items.
- sample(per_group: int, unique_samples: bool = True)[source]#
Returns new FrameGroupSet with groups sampled from current groups.
Note that the order of items in the new groups will not match order of items in the groups from which samples are drawn.
- Parameters:
per_group – The number of samples to take from each group.
unique_samples – Whether to ensure that there are no shared items in the resulting groups.
- Returns:
New FrameGroupSet.
- class sleap.info.feature_suggestions.FrameItem(video: Video, frame_idx: int)[source]#
Just a simple wrapper for (video, frame_idx), plus method to get image.
- class sleap.info.feature_suggestions.ItemStack(items: List = _Nothing.NOTHING, data: Optional[ndarray] = None, ownership: Optional[List[tuple]] = None, meta: List = _Nothing.NOTHING, group_sets: List[FrameGroupSet] = _Nothing.NOTHING)[source]#
Container for items, each item can “own” one or more rows of data.
- items#
The list of items
- Type:
List
- data#
An ndarray with rows of data corresponding to items.
- Type:
Optional[numpy.ndarray]
- ownership#
List which specifies which rows of data correspond to which items.
- Type:
Optional[List[tuple]]
- meta#
List which stores metadata about each operation on stack.
- Type:
List
- group_sets#
List of GroupSets of items.
- Type:
- brisk_bag_of_features(brisk_threshold=40, vocab_size=20)[source]#
Transform data using bag of features based on brisk features.
- property current_groupset#
Gets current (most recent) group set.
- extend_ownership(ownership, row_count)[source]#
Extends an ownership list with number of rows owned by next item.
- hog_bag_of_features(brisk_threshold=40, vocab_size=20)[source]#
Transforms data into bag of features vector of hog descriptors.
- class sleap.info.feature_suggestions.ParallelFeaturePipeline(pipeline: FeatureSuggestionPipeline, videos_as_dicts: List[Dict])[source]#
Enables easy per-video pipeline parallelization for feature suggestions.
Create a
FeatureSuggestionPipeline
with the desired parameters, and then callParallelFeaturePipeline.run()
with the pipeline and the list of videos to process in parallel. This will take care of serializing the videos, running the pipelines in a process pool, and then deserializing the results back into a single list ofSuggestionFrame
objects.