-
-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add prepare_data
method to generate and save protocol data on disk
#1500
Closed
clement-pages
wants to merge
17
commits into
pyannote:develop
from
clement-pages:feat/data_preparation
Closed
Add prepare_data
method to generate and save protocol data on disk
#1500
clement-pages
wants to merge
17
commits into
pyannote:develop
from
clement-pages:feat/data_preparation
Conversation
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
The goal of this method is to generate the data needed by the task and save it on disk for future uses, for example by the `setup` method. The objective is to avoid systematically recreating data on each process at the beginning of a training
hbredin
reviewed
Oct 13, 2023
Comment on lines
81
to
94
data_dict = pickle.load(data_file) | ||
self.metadata = data_dict["metadata"] | ||
self.audios = data_dict["audios"] | ||
self.audio_infos= data_dict["audio_infos"] | ||
self.audio_encodings = data_dict["audio_encodings"] | ||
self.annotated_duration = data_dict["annotated_duration"] | ||
self.annotated_regions = data_dict["annotated_regions"] | ||
self.annotated_classes = data_dict["annotated_classes"] | ||
self.annotations = data_dict["annotations"] | ||
self.metadata_unique_values = data_dict["metadata_unique_values"] | ||
if isinstance(self.protocol, SegmentationProtocol): | ||
self.classes = data_dict["classes"] | ||
if self.has_validation: | ||
self.validation_chunks = data_dict["validation_chunks"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this can probably be replaced by:
for key, value in data_dict.items():
setattr(self, key) = value
Now all the segmentations tasks in `pyannote` inherit the `SegmentationTask` (previously `SegmentationTaskMixin`), which inherits the `Task` class. This commit also adds a `prepared_data` attribute to the `Task` class. That attribute is a dict which contains all the prepared data by the `prepare_data` method.
…note-audio into feat/data_preparation
One for the test of the `MultiLabelSegmentation` task, and the other for the test of the `SupervisedRepresentationLearningWithArcFace` task.
This eliminates the need to reload pickle data in setup when in the main process
…note-audio into feat/data_preparation
This issue occured when a list of classes was specified during `MultiLabelSegmentation` instanciation.
* use npz archive instead pickle to save task data * improve code readability * improve(task): update numpy array dtypes In order to use types whose size better machtes the contents of the arrays * remove `end` entry from `annotated_regions` numpy array This entry was redundant with the start and duration entries, since `end` = `start` + `duration`. * fix: allow data preparation to be finished when task has no validation * improve: clear data lists after assignation to `self.prepared_data` This is to avoid data redundancy in the `prepare_data` method --------- Co-authored-by: clement-pages <clement.pages@irit.fr>
Looks like you closed this PR? |
This is not me... I think the PR was closed because I have renamed the branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal of this pull request is to reduce the time needed to setup a task in
pyannote
by implementingprepare_data
method.prepare_data
generates the data needed by the task and save it on disk for future uses, for example by thesetup
method. The objective is to avoid systematically recreating data on each process at the beginning of a training.This PR also proposes to reorganize the segmentation tasks hierarchy. Now, the
SegmentationTask
(previouslySegmentationTaskMixin
) inherits theTask
class. All the segmentation tasks inherit only from theSegmentationTask
(instead ofTask
andSegmentationTaskMixin
)