Skip to content

Commit

Permalink
fix in data augmentation on tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Natooz committed May 2, 2023
1 parent a374d5f commit 456a6ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion miditok/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""

CURRENT_VERSION_PACKAGE = "2.0.3" # used when saving the config of a tokenizer
CURRENT_VERSION_PACKAGE = "2.0.4" # used when saving the config of a tokenizer

MIDI_FILES_EXTENSIONS = [".mid", ".midi", ".MID", ".MIDI"]

Expand Down
7 changes: 5 additions & 2 deletions miditok/data_augmentation/data_augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ def data_augmentation_dataset(
for track, (_, is_drum) in zip(ids, programs):
if is_drum: # we dont augment drums
continue
corrected_offsets = deepcopy(offsets)
vel_dim = int(128 / len(tokenizer.velocities))
corrected_offsets[1] = [int(off / vel_dim) for off in corrected_offsets[1]]
aug = data_augmentation_tokens(
np.array(track),
tokenizer,
*offsets,
*corrected_offsets,
all_offset_combinations=all_offset_combinations,
)
if len(aug) == 0:
Expand Down Expand Up @@ -220,7 +223,7 @@ def get_offsets(
as a tuple of two booleans. (default: (True, True))
:param midi: midi object to augment (default: None)
:param ids: token ids as a list of tracks (default: None)
:return: augmented MIDI objects.
:return: the offsets of pitch, velocity and duration features, in "absolute" value
"""
offsets = []

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
author='Nathan Fradet',
url='https://github.com/Natooz/MidiTok',
packages=find_packages(exclude=("tests",)),
version='2.0.3',
version='2.0.4',
license='MIT',
description='A convenient MIDI tokenizer for Deep Learning networks, with multiple encoding strategies',
long_description=long_description,
Expand Down

0 comments on commit 456a6ce

Please sign in to comment.