yangwang825 commited on
Commit
f23734d
·
verified ·
1 Parent(s): 37adfc4

Update irmas.py

Browse files
Files changed (1) hide show
  1. irmas.py +5 -0
irmas.py CHANGED
@@ -102,10 +102,14 @@ class IRMAS(datasets.GeneratorBasedBuilder):
102
  # Find all occurrences of the pattern
103
  items = re.findall(pattern, filename)
104
  return items
 
 
 
105
 
106
  if split == 'train':
107
  for guid, audio_path in enumerate(audio_filepaths):
108
  labels = extract_bracketed_items(audio_path)
 
109
  labels = [label for label in labels if label in INSTRUMENTS]
110
  yield guid, {
111
  "id": str(guid),
@@ -121,6 +125,7 @@ class IRMAS(datasets.GeneratorBasedBuilder):
121
  with open(audio_path.replace('.wav', '.txt'), 'r') as f:
122
  for line in f:
123
  labels.append(line.strip())
 
124
  yield guid, {
125
  "id": str(guid),
126
  "file": audio_path,
 
102
  # Find all occurrences of the pattern
103
  items = re.findall(pattern, filename)
104
  return items
105
+
106
+ def deduplicate(lst):
107
+ return list(dict.fromkeys(lst))
108
 
109
  if split == 'train':
110
  for guid, audio_path in enumerate(audio_filepaths):
111
  labels = extract_bracketed_items(audio_path)
112
+ labels = deduplicate(labels)
113
  labels = [label for label in labels if label in INSTRUMENTS]
114
  yield guid, {
115
  "id": str(guid),
 
125
  with open(audio_path.replace('.wav', '.txt'), 'r') as f:
126
  for line in f:
127
  labels.append(line.strip())
128
+ labels = deduplicate(labels)
129
  yield guid, {
130
  "id": str(guid),
131
  "file": audio_path,