Skip to content
Merged

V180 #97

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
593084c
Removing output PNG from version control.
napulen Jun 21, 2022
0094e8a
Modifying sonifyencoding.
napulen Jun 21, 2022
a6119f6
Modifying notebook.
napulen Jun 21, 2022
21b2307
Adding pngs to gitignore.
napulen Jun 21, 2022
2fa363a
Adding noteboks.
napulen Jun 21, 2022
5d1be21
Merge branch 'main' of github.com:napulen/AugmentedNet into main
napulen Jun 22, 2022
c07f233
Adding MeterDistribution plot.
napulen Jun 21, 2022
0463e7a
Adding notebook for obtaining meterdistribution.
napulen Jun 22, 2022
cc702a7
Updating texturize_example.
napulen Jun 22, 2022
71c6e4c
Adding Duration14 as a default input representation.
napulen Jun 22, 2022
55fd059
Merge pull request #91 from napulen/cli_default_values
napulen Jun 22, 2022
720e2c4
Abstracting (annotation, score) pairs to getAnnotationScoreDataset
napulen Jun 22, 2022
6b3cceb
Renaming LocalKey38 and TonicizedKey38.
napulen Jun 22, 2022
652010e
Merge pull request #92 from napulen/key38
napulen Jun 22, 2022
375cc5a
Renaming MeasureNoteOnset14 and introducing intermediate representati…
napulen Jun 23, 2022
5419f99
Merge pull request #93 from napulen/measurenoteonset14
napulen Jun 23, 2022
0bc8a23
Adding more options for experiment names
napulen Jun 23, 2022
23bdac0
Merge pull request #94 from napulen/experiment_names
napulen Jun 23, 2022
db37cc5
Reverse logic of transposition arg.
napulen Jun 23, 2022
c7c55ee
Merge pull request #96 from napulen/transposition_cli
napulen Jun 23, 2022
edf7a80
Changing version to 1.8.0
napulen Jun 23, 2022
0754f8b
Simplifying list comprehension in models.
napulen Jun 23, 2022
965dbf3
Merge branch 'v180' of github.com:napulen/AugmentedNet into v180
napulen Jun 23, 2022
d2bca99
Formatting with black.
napulen Jun 23, 2022
294bc83
Adding the fix to the existing texturization patterns for 3/4 and 6/8…
napulen Jun 22, 2022
44c88f9
Merge pull request #98 from napulen/texturization_34_68
napulen Jun 23, 2022
bb00a65
Adding MeasureOnset7 and NoteOnset7 to available_input_representations.
napulen Jun 23, 2022
2776692
Adding pretrained model for v1.8.0.
napulen Jun 25, 2022
e454b90
Removing padding from evaluation.
napulen Jun 25, 2022
08f4a4c
Renaming haydnop20 to haydnsun
napulen Jun 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,5 @@ defaults.json

# Ignore memmap files
*.mmap

notebooks/**/*.png
Binary file modified AugmentedNet.hdf5
Binary file not shown.
2 changes: 1 addition & 1 deletion AugmentedNet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import glob

__author__ = "Néstor Nápoles López"
__version__ = "1.7.1"
__version__ = "1.8.0"
modules = glob.glob(join(dirname(__file__), "*.py"))
__all__ = [
basename(f)[:-3]
Expand Down
26 changes: 19 additions & 7 deletions AugmentedNet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,29 @@ class DefaultArguments(object):
npz = {
"synthetic": False,
"texturizeEachTransposition": False,
"dataAugmentation": True,
"noTransposition": False,
"collections": ["bps"],
"testCollections": ["bps"],
"inputRepresentations": ["Bass19", "Chromagram19"],
"inputRepresentations": [
"Bass19",
"Chromagram19",
"MeasureNoteOnset14",
],
"outputRepresentations": [
"Alto35",
"Bass35",
# "ChordQuality11",
# "ChordRoot35",
"HarmonicRhythm7",
# "Inversion4",
"LocalKey35",
"LocalKey38",
"PitchClassSet121",
# "PrimaryDegree22",
"RomanNumeral31",
# "SecondaryDegree22",
"Soprano35",
"Tenor35",
"TonicizedKey35",
"TonicizedKey38",
],
"sequenceLength": 640,
"scrutinizeData": False,
Expand Down Expand Up @@ -117,9 +121,9 @@ def npz(is_parent_parser=False):
help="Include training files from a specific corpus/collection.",
)
parser.add_argument(
"--dataAugmentation",
"--noTransposition",
action="store_true",
help="Perform data augmentation on the training set.",
help="Disable transposition data augmentation on the training set.",
)
parser.add_argument(
"--inputRepresentations",
Expand Down Expand Up @@ -183,7 +187,15 @@ def train():
parser = ArgumentParser(description=train_description, parents=parents)
parser.add_argument(
"experiment_name",
choices=["testset", "validationset", "prototyping", "debug"],
choices=[
"local",
"computecanada",
"colab",
"ablation",
"validationset",
"testset",
"debug",
],
help="A short name for this experiment.",
)
parser.add_argument(
Expand Down
10 changes: 2 additions & 8 deletions AugmentedNet/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Common hardcoded variables throughout the code."""

from .data import available_collections
from .data import getAnnotationScoreDataset

# Number of decimals to the right of the decimal point
FLOATSCALE = 4
Expand All @@ -11,10 +11,4 @@

DATASETSUMMARYFILE = "dataset_summary.tsv"

ANNOTATIONSCOREDUPLES = {}
DATASPLITS = {"training": [], "validation": [], "test": []}

for module in available_collections.values():
ANNOTATIONSCOREDUPLES.update(module.annotation_score_duples)
for split in DATASPLITS:
DATASPLITS[split].extend(module.splits[split])
ANNOTATIONSCOREDUPLES, DATASPLITS = getAnnotationScoreDataset()
18 changes: 17 additions & 1 deletion AugmentedNet/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,25 @@
available_collections = {
"abc": abc_dcml,
"bps": bps,
"haydnop20": haydnsun,
"haydnsun": haydnsun,
"mps": mps,
"tavern": tavern,
"wir": wir,
"wirwtc": wirwtc,
}


def getAnnotationScoreDataset(collections=[]):
"""Return the available (annotation, score) pairs in the dataset."""
allCollections = list(available_collections.keys())
collections = collections or allCollections
duples = {}
splits = {"training": [], "validation": [], "test": []}
for collection in collections:
if collection not in allCollections:
raise KeyError()
module = available_collections[collection]
duples.update(module.annotation_score_duples)
for split in splits:
splits[split].extend(module.splits[split])
return duples, splits
96 changes: 48 additions & 48 deletions AugmentedNet/data/haydnsun.py
Original file line number Diff line number Diff line change
@@ -1,131 +1,131 @@
annotation_score_duples = {
"haydnop20-no1-1": (
"haydnsun-no1-1": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No1/1/analysis.txt",
"rawdata/haydn_op20_harm/op20/1/i/op20n1-01.krn",
),
"haydnop20-no1-2": (
"haydnsun-no1-2": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No1/2/analysis.txt",
"rawdata/haydn_op20_harm/op20/1/ii/op20n1-02.krn",
),
"haydnop20-no1-3": (
"haydnsun-no1-3": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No1/3/analysis.txt",
"rawdata/haydn_op20_harm/op20/1/iii/op20n1-03.krn",
),
"haydnop20-no1-4": (
"haydnsun-no1-4": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No1/4/analysis.txt",
"rawdata/haydn_op20_harm/op20/1/iv/op20n1-04.krn",
),
"haydnop20-no2-1": (
"haydnsun-no2-1": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No2/1/analysis.txt",
"rawdata/haydn_op20_harm/op20/2/i/op20n2-01.krn",
),
"haydnop20-no2-2": (
"haydnsun-no2-2": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No2/2/analysis.txt",
"rawdata/haydn_op20_harm/op20/2/ii/op20n2-02.krn",
),
"haydnop20-no2-3": (
"haydnsun-no2-3": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No2/3/analysis.txt",
"rawdata/haydn_op20_harm/op20/2/iii/op20n2-03.krn",
),
"haydnop20-no2-4": (
"haydnsun-no2-4": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No2/4/analysis.txt",
"rawdata/haydn_op20_harm/op20/2/iv/op20n2-04.krn",
),
"haydnop20-no3-1": (
"haydnsun-no3-1": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No3/1/analysis.txt",
"rawdata/haydn_op20_harm/op20/3/i/op20n3-01.krn",
),
"haydnop20-no3-2": (
"haydnsun-no3-2": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No3/2/analysis.txt",
"rawdata/haydn_op20_harm/op20/3/ii/op20n3-02.krn",
),
"haydnop20-no3-3": (
"haydnsun-no3-3": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No3/3/analysis.txt",
"rawdata/haydn_op20_harm/op20/3/iii/op20n3-03.krn",
),
"haydnop20-no3-4": (
"haydnsun-no3-4": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No3/4/analysis.txt",
"rawdata/haydn_op20_harm/op20/3/iv/op20n3-04.krn",
),
"haydnop20-no4-1": (
"haydnsun-no4-1": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No4/1/analysis.txt",
"rawdata/haydn_op20_harm/op20/4/i/op20n4-01.krn",
),
"haydnop20-no4-2": (
"haydnsun-no4-2": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No4/2/analysis.txt",
"rawdata/haydn_op20_harm/op20/4/ii/op20n4-02.krn",
),
"haydnop20-no4-3": (
"haydnsun-no4-3": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No4/3/analysis.txt",
"rawdata/haydn_op20_harm/op20/4/iii/op20n4-03.krn",
),
"haydnop20-no4-4": (
"haydnsun-no4-4": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No4/4/analysis.txt",
"rawdata/haydn_op20_harm/op20/4/iv/op20n4-04.krn",
),
"haydnop20-no5-1": (
"haydnsun-no5-1": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No5/1/analysis.txt",
"rawdata/haydn_op20_harm/op20/5/i/op20n5-01.krn",
),
"haydnop20-no5-2": (
"haydnsun-no5-2": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No5/2/analysis.txt",
"rawdata/haydn_op20_harm/op20/5/ii/op20n5-02.krn",
),
"haydnop20-no5-3": (
"haydnsun-no5-3": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No5/3/analysis.txt",
"rawdata/haydn_op20_harm/op20/5/iii/op20n5-03.krn",
),
"haydnop20-no5-4": (
"haydnsun-no5-4": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No5/4/analysis.txt",
"rawdata/haydn_op20_harm/op20/5/iv/op20n5-04.krn",
),
"haydnop20-no6-1": (
"haydnsun-no6-1": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No6/1/analysis.txt",
"rawdata/haydn_op20_harm/op20/6/i/op20n6-01.krn",
),
"haydnop20-no6-2": (
"haydnsun-no6-2": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No6/2/analysis.txt",
"rawdata/haydn_op20_harm/op20/6/ii/op20n6-02.krn",
),
"haydnop20-no6-3": (
"haydnsun-no6-3": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No6/3/analysis.txt",
"rawdata/haydn_op20_harm/op20/6/iii/op20n6-03.krn",
),
"haydnop20-no6-4": (
"haydnsun-no6-4": (
"rawdata/When-in-Rome/Corpus/Quartets/Haydn,_Franz_Joseph/Op20_No6/4/analysis.txt",
"rawdata/haydn_op20_harm/op20/6/iv/op20n6-04.krn",
),
}

splits = {
"training": [
"haydnop20-no6-3",
"haydnop20-no1-1",
"haydnop20-no4-1",
"haydnop20-no4-3",
"haydnop20-no1-3",
"haydnop20-no6-2",
"haydnop20-no3-1",
"haydnop20-no5-1",
"haydnop20-no1-4",
"haydnop20-no2-3",
"haydnop20-no5-4",
"haydnop20-no3-2",
"haydnop20-no4-4",
"haydnop20-no2-1",
"haydnop20-no4-2",
"haydnop20-no6-1",
"haydnsun-no6-3",
"haydnsun-no1-1",
"haydnsun-no4-1",
"haydnsun-no4-3",
"haydnsun-no1-3",
"haydnsun-no6-2",
"haydnsun-no3-1",
"haydnsun-no5-1",
"haydnsun-no1-4",
"haydnsun-no2-3",
"haydnsun-no5-4",
"haydnsun-no3-2",
"haydnsun-no4-4",
"haydnsun-no2-1",
"haydnsun-no4-2",
"haydnsun-no6-1",
],
"validation": [
"haydnop20-no1-2",
"haydnop20-no2-4",
"haydnop20-no3-3",
"haydnop20-no5-2",
"haydnsun-no1-2",
"haydnsun-no2-4",
"haydnsun-no3-3",
"haydnsun-no5-2",
],
"test": [
"haydnop20-no2-2",
"haydnop20-no3-4",
"haydnop20-no5-3",
"haydnop20-no6-4",
"haydnsun-no2-2",
"haydnsun-no3-4",
"haydnsun-no5-3",
"haydnsun-no6-4",
],
}
8 changes: 4 additions & 4 deletions AugmentedNet/dataset_npz_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def correctSplit(split, testSetOn):
def generateDataset(
synthetic,
texturizeEachTransposition,
dataAugmentation,
noTransposition,
collections,
testCollections,
inputRepresentations,
Expand Down Expand Up @@ -108,11 +108,11 @@ def generateDataset(
df = joint_parser.from_tsv(tsvlocation)
if scrutinizeData and split == "training":
df = scrutinize(df)
if dataAugmentation and split == "training":
if noTransposition or split != "training":
transpositions = ["P1"]
else:
transpositions = _getTranspositions(df, transpositionKeys)
print("\t", transpositions)
else:
transpositions = ["P1"]
if synthetic:
if not texturizeEachTransposition:
# once per file
Expand Down
4 changes: 2 additions & 2 deletions AugmentedNet/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ def predict(model, inputPath):
if not notes:
continue
bass = sorted(notes, key=lambda n: n[1])[0][0]
thiskey = analysis.LocalKey35
tonicizedKey = analysis.TonicizedKey35
thiskey = analysis.LocalKey38
tonicizedKey = analysis.TonicizedKey38
pcset = analysis.PitchClassSet121
rn2, chordLabel = resolveRomanNumeral(
analysis.Bass35,
Expand Down
Loading