kjysmu commited on
Commit
4e46a55
1 Parent(s): 1e00a74
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. app.py +738 -4
  3. dataset/README.md +31 -0
  4. dataset/__pycache__/vevo_dataset.cpython-37.pyc +0 -0
  5. dataset/vevo_dataset.py +720 -0
  6. dataset/vevo_meta/chord.json +1 -0
  7. dataset/vevo_meta/chord_attr.json +1 -0
  8. dataset/vevo_meta/chord_attr_inv.json +16 -0
  9. dataset/vevo_meta/chord_inv.json +1 -0
  10. dataset/vevo_meta/chord_root.json +1 -0
  11. dataset/vevo_meta/chord_root_inv.json +15 -0
  12. dataset/vevo_meta/exclude.txt +1 -0
  13. dataset/vevo_meta/idlist.txt +748 -0
  14. dataset/vevo_meta/top_chord.txt +30 -0
  15. default_sound_font.sf2 +3 -0
  16. model/__pycache__/music_transformer.cpython-37.pyc +0 -0
  17. model/__pycache__/positional_encoding.cpython-37.pyc +0 -0
  18. model/__pycache__/positional_encoding.cpython-38.pyc +0 -0
  19. model/__pycache__/rpr.cpython-37.pyc +0 -0
  20. model/__pycache__/rpr.cpython-38.pyc +0 -0
  21. model/__pycache__/video_music_transformer.cpython-37.pyc +0 -0
  22. model/__pycache__/video_music_transformer.cpython-38.pyc +0 -0
  23. model/__pycache__/video_regression.cpython-37.pyc +0 -0
  24. model/__pycache__/video_regression.cpython-38.pyc +0 -0
  25. model/loss.py +46 -0
  26. model/music_transformer.py +177 -0
  27. model/positional_encoding.py +23 -0
  28. model/rpr.py +455 -0
  29. model/video_music_transformer.py +205 -0
  30. model/video_regression.py +64 -0
  31. packages.txt +2 -0
  32. requirements.txt +24 -0
  33. saved_models/AMT/README.md +1 -0
  34. saved_models/AMT/best_loss_weights.pickle +3 -0
  35. saved_models/AMT/best_rmse_weights.pickle +3 -0
  36. third_party/midi_processor/__pycache__/processor.cpython-37.pyc +0 -0
  37. third_party/midi_processor/__pycache__/processor.cpython-38.pyc +0 -0
  38. third_party/midi_processor/processor.py +261 -0
  39. utilities/__init__.py +0 -0
  40. utilities/__pycache__/__init__.cpython-37.pyc +0 -0
  41. utilities/__pycache__/__init__.cpython-38.pyc +0 -0
  42. utilities/__pycache__/argument_funcs.cpython-37.pyc +0 -0
  43. utilities/__pycache__/chord_to_midi.cpython-37.pyc +0 -0
  44. utilities/__pycache__/chord_to_midi.cpython-38.pyc +0 -0
  45. utilities/__pycache__/constants.cpython-37.pyc +0 -0
  46. utilities/__pycache__/constants.cpython-38.pyc +0 -0
  47. utilities/__pycache__/device.cpython-37.pyc +0 -0
  48. utilities/__pycache__/device.cpython-38.pyc +0 -0
  49. utilities/argument_funcs.py +275 -0
  50. utilities/chord_to_midi.py +316 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.sf2 filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -1,7 +1,741 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
1
  import gradio as gr
2
+ from pathlib import Path
3
 
4
+ import torch
5
+ import shutil
6
+ import os
7
+ import subprocess
8
+ import cv2
9
+ import math
10
+ import clip
11
+ import numpy as np
12
+ from PIL import Image
13
+ from scenedetect import open_video, SceneManager, split_video_ffmpeg
14
+ from scenedetect.detectors import ContentDetector, AdaptiveDetector
15
+ from scenedetect.video_splitter import split_video_ffmpeg
16
+ from scenedetect.scene_manager import save_images
17
+ from utilities.constants import *
18
+ from utilities.chord_to_midi import *
19
+
20
+ from model.video_music_transformer import VideoMusicTransformer
21
+ from model.video_regression import VideoRegression
22
+
23
+ import json
24
+ from midi2audio import FluidSynth
25
+ import moviepy.editor as mp
26
+ from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
27
+ import random
28
+ from moviepy.editor import *
29
+ import time
30
+
31
+ from tqdm import tqdm
32
+ from huggingface_hub import snapshot_download
33
+
34
+ from gradio import Markdown
35
+
36
+ all_key_names = ['C major', 'G major', 'D major', 'A major',
37
+ 'E major', 'B major', 'F major', 'Bb major',
38
+ 'Eb major', 'Ab major', 'Db major', 'Gb major',
39
+ 'A minor', 'E minor', 'B minor', 'F# minor',
40
+ 'C# minor', 'G# minor', 'D minor', 'G minor',
41
+ 'C minor', 'F minor', 'Bb minor', 'Eb minor',
42
+ ]
43
+
44
+ traspose_key_dic = {
45
+ 'F major' : -7,
46
+ 'Gb major' : -6,
47
+ 'G major' : -5,
48
+ 'Ab major' : -4,
49
+ 'A major' : -3,
50
+ 'Bb major' : -2,
51
+ 'B major' : -1,
52
+ 'C major' : 0,
53
+ 'Db major' : 1,
54
+ 'D major' : 2,
55
+ 'Eb major' : 3,
56
+ 'E major' : 4,
57
+ 'D minor' : -7,
58
+ 'Eb minor' : -6,
59
+ 'E minor' : -5,
60
+ 'F minor' : -4,
61
+ 'F# minor' : -3,
62
+ 'G minor' : -2,
63
+ 'G# minor' : -1,
64
+ 'A minor' : 0,
65
+ 'Bb minor' : 1,
66
+ 'B minor' : 2,
67
+ 'C minor' : 3,
68
+ 'C# minor' : 4
69
+ }
70
+
71
+ flatsharpDic = {
72
+ 'Db':'C#',
73
+ 'Eb':'D#',
74
+ 'Gb':'F#',
75
+ 'Ab':'G#',
76
+ 'Bb':'A#'
77
+ }
78
+
79
+ max_conseq_N = 0
80
+ max_conseq_chord = 2
81
+ tempo = 120
82
+ duration = 2
83
+
84
+ min_loudness = 0 # Minimum loudness level in the input range
85
+ max_loudness = 50 # Maximum loudness level in the input range
86
+ min_velocity = 49 # Minimum velocity value in the output range
87
+ max_velocity = 112 # Maximum velocity value in the output range
88
+
89
+
90
+ def split_video_into_frames(video, frame_dir):
91
+ output_path = os.path.join(frame_dir, f"%03d.jpg")
92
+ cmd = f"ffmpeg -i {video} -vf \"select=bitor(gte(t-prev_selected_t\,1)\,isnan(prev_selected_t))\" -vsync 0 -qmin 1 -q:v 1 {output_path}"
93
+ subprocess.call(cmd, shell=True)
94
+
95
+ def gen_semantic_feature(frame_dir, semantic_dir):
96
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
97
+ model, preprocess = clip.load("ViT-L/14@336px", device=device)
98
+ file_names = os.listdir(frame_dir)
99
+ sorted_file_names = sorted(file_names)
100
+
101
+ output_path = semantic_dir / "semantic.npy"
102
+ features = torch.cuda.FloatTensor(len(sorted_file_names), 768).fill_(0)
103
+
104
+ for idx, file_name in enumerate(sorted_file_names):
105
+ fpath = frame_dir / file_name
106
+ image = preprocess(Image.open(fpath)).unsqueeze(0).to(device)
107
+ with torch.no_grad():
108
+ image_features = model.encode_image(image)
109
+ features[idx] = image_features[0]
110
+ features = features.cpu().numpy()
111
+ np.save(output_path, features)
112
+
113
+ def gen_emotion_feature(frame_dir, emotion_dir):
114
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
115
+ model, preprocess = clip.load("ViT-L/14@336px", device=device)
116
+ text = clip.tokenize(["exciting", "fearful", "tense", "sad", "relaxing", "neutral"]).to(device)
117
+
118
+ file_names = os.listdir(frame_dir)
119
+ sorted_file_names = sorted(file_names)
120
+ output_path = emotion_dir / "emotion.lab"
121
+
122
+ emolist = []
123
+ for file_name in sorted_file_names:
124
+ fpath = frame_dir / file_name
125
+ image = preprocess(Image.open(fpath)).unsqueeze(0).to(device)
126
+ with torch.no_grad():
127
+ logits_per_image, logits_per_text = model(image, text)
128
+ probs = logits_per_image.softmax(dim=-1).cpu().numpy()
129
+
130
+ fp1 = format(probs[0][0], ".4f")
131
+ fp2 = format(probs[0][1], ".4f")
132
+ fp3 = format(probs[0][2], ".4f")
133
+ fp4 = format(probs[0][3], ".4f")
134
+ fp5 = format(probs[0][4], ".4f")
135
+ fp6 = format(probs[0][5], ".4f")
136
+
137
+ emo_val = str(fp1) +" "+ str(fp2) +" "+ str(fp3) +" "+ str(fp4) +" "+ str(fp5) + " " + str(fp6)
138
+ emolist.append(emo_val)
139
+
140
+ with open(output_path ,'w' ,encoding = 'utf-8') as f:
141
+ f.write("time exciting_prob fearful_prob tense_prob sad_prob relaxing_prob neutral_prob\n")
142
+ for i in range(0, len(emolist) ):
143
+ f.write(str(i) + " "+emolist[i]+"\n")
144
+
145
+ def gen_scene_feature(video, scene_dir):
146
+ video_stream = open_video(str(video))
147
+
148
+ scene_manager = SceneManager()
149
+ scene_manager.add_detector(AdaptiveDetector())
150
+ scene_manager.detect_scenes(video_stream, show_progress=False)
151
+ scene_list = scene_manager.get_scene_list()
152
+
153
+ sec = 0
154
+ scenedict = {}
155
+ for idx, scene in enumerate(scene_list):
156
+ end_int = math.ceil(scene[1].get_seconds())
157
+ for s in range (sec, end_int):
158
+ scenedict[s] = str(idx)
159
+ sec += 1
160
+
161
+ fpathname = scene_dir / "scene.lab"
162
+ with open(fpathname,'w',encoding = 'utf-8') as f:
163
+ for i in range(0, len(scenedict)):
164
+ f.write(str(i) + " "+scenedict[i]+"\n")
165
+
166
+ def gen_scene_offset_feature(scene_dir, scene_offset_dir):
167
+ src = scene_dir / "scene.lab"
168
+ tgt = scene_offset_dir / "scene_offset.lab"
169
+
170
+ id_list = []
171
+ with open(src, encoding = 'utf-8') as f:
172
+ for line in f:
173
+ line = line.strip()
174
+ line_arr = line.split(" ")
175
+ if len(line_arr) == 2 :
176
+ time = int(line_arr[0])
177
+ scene_id = int(line_arr[1])
178
+ id_list.append(scene_id)
179
+
180
+ offset_list = []
181
+ current_id = id_list[0]
182
+ offset = 0
183
+ for i in range(len(id_list)):
184
+ if id_list[i] != current_id:
185
+ current_id = id_list[i]
186
+ offset = 0
187
+ offset_list.append(offset)
188
+ offset += 1
189
+
190
+ with open(tgt,'w',encoding = 'utf-8') as f:
191
+ for i in range(0, len(offset_list)):
192
+ f.write(str(i) + " " + str(offset_list[i]) + "\n")
193
+
194
+ def gen_motion_feature(video, motion_dir):
195
+ cap = cv2.VideoCapture(str(video))
196
+ prev_frame = None
197
+ prev_time = 0
198
+ motion_value = 0
199
+ motiondict = {}
200
+
201
+ while cap.isOpened():
202
+ ret, frame = cap.read()
203
+ if not ret:
204
+ break
205
+ curr_time = cap.get(cv2.CAP_PROP_POS_MSEC) / 1000.0
206
+ motiondict[0] = "0.0000"
207
+ if prev_frame is not None and curr_time - prev_time >= 1:
208
+ diff = cv2.absdiff(frame, prev_frame)
209
+ diff_rgb = cv2.cvtColor(diff, cv2.COLOR_BGR2RGB)
210
+ motion_value = diff_rgb.mean()
211
+ motion_value = format(motion_value, ".4f")
212
+ motiondict[int(curr_time)] = str(motion_value)
213
+ prev_time = int(curr_time)
214
+ prev_frame = frame.copy()
215
+ cap.release()
216
+ cv2.destroyAllWindows()
217
+ fpathname = motion_dir / "motion.lab"
218
+
219
+ with open(fpathname,'w',encoding = 'utf-8') as f:
220
+ for i in range(0, len(motiondict)):
221
+ f.write(str(i) + " "+motiondict[i]+"\n")
222
+
223
+
224
+ # def get_motion_feature(scene_dir, scene_offset_dir):
225
+ # fpath_emotion = emotion_dir / "emotion.lab"
226
+ # fpath_motion = motion_dir / "motion.lab"
227
+
228
+ def get_scene_offset_feature(scene_offset_dir, max_seq_chord=300, max_seq_video=300):
229
+ feature_scene_offset = np.empty(max_seq_video)
230
+ feature_scene_offset.fill(SCENE_OFFSET_PAD)
231
+ fpath_scene_offset = scene_offset_dir / "scene_offset.lab"
232
+
233
+ with open(fpath_scene_offset, encoding = 'utf-8') as f:
234
+ for line in f:
235
+ line = line.strip()
236
+ line_arr = line.split(" ")
237
+ time = line_arr[0]
238
+ time = int(time)
239
+ if time >= max_seq_chord:
240
+ break
241
+ sceneID = line_arr[1]
242
+ feature_scene_offset[time] = int(sceneID)+1
243
+
244
+ feature_scene_offset = torch.from_numpy(feature_scene_offset)
245
+ feature_scene_offset = feature_scene_offset.to(torch.float32)
246
+
247
+ return feature_scene_offset
248
+
249
+ def get_motion_feature(motion_dir, max_seq_chord=300, max_seq_video=300):
250
+ fpath_motion = motion_dir / "motion.lab"
251
+ feature_motion = np.empty(max_seq_video)
252
+ feature_motion.fill(MOTION_PAD)
253
+ with open(fpath_motion, encoding = 'utf-8') as f:
254
+ for line in f:
255
+ line = line.strip()
256
+ line_arr = line.split(" ")
257
+ time = line_arr[0]
258
+ time = int(time)
259
+ if time >= max_seq_chord:
260
+ break
261
+ motion = line_arr[1]
262
+ feature_motion[time] = float(motion)
263
+
264
+ feature_motion = torch.from_numpy(feature_motion)
265
+ feature_motion = feature_motion.to(torch.float32)
266
+ return feature_motion
267
+
268
+ def get_emotion_feature(emotion_dir, max_seq_chord=300, max_seq_video=300):
269
+ fpath_emotion = emotion_dir / "emotion.lab"
270
+ feature_emotion = np.empty((max_seq_video, 6))
271
+ feature_emotion.fill(EMOTION_PAD)
272
+
273
+ with open(fpath_emotion, encoding = 'utf-8') as f:
274
+ for line in f:
275
+ line = line.strip()
276
+ line_arr = line.split(" ")
277
+ if line_arr[0] == "time":
278
+ continue
279
+ time = line_arr[0]
280
+ time = int(time)
281
+ if time >= max_seq_chord:
282
+ break
283
+ emo1, emo2, emo3, emo4, emo5, emo6 = \
284
+ line_arr[1],line_arr[2],line_arr[3],line_arr[4],line_arr[5],line_arr[6]
285
+ emoList = [ float(emo1), float(emo2), float(emo3), float(emo4), float(emo5), float(emo6) ]
286
+ emoList = np.array(emoList)
287
+ feature_emotion[time] = emoList
288
+
289
+ feature_emotion = torch.from_numpy(feature_emotion)
290
+ feature_emotion = feature_emotion.to(torch.float32)
291
+ return feature_emotion
292
+
293
+ def get_semantic_feature(semantic_dir, max_seq_chord=300, max_seq_video=300):
294
+ fpath_semantic = semantic_dir / "semantic.npy"
295
+
296
+ video_feature = np.load(fpath_semantic)
297
+ dim_vf = video_feature.shape[1]
298
+
299
+ video_feature_tensor = torch.from_numpy( video_feature )
300
+ feature_semantic = torch.full((max_seq_video, dim_vf,), SEMANTIC_PAD , dtype=torch.float32, device=torch.device("cpu"))
301
+
302
+ if(video_feature_tensor.shape[0] < max_seq_video):
303
+ feature_semantic[:video_feature_tensor.shape[0]] = video_feature_tensor
304
+ else:
305
+ feature_semantic = video_feature_tensor[:max_seq_video]
306
+
307
+ return feature_semantic
308
+
309
+
310
+ def text_clip(text: str, duration: int, start_time: int = 0):
311
+ t = TextClip(text, font='Georgia-Regular', fontsize=24, color='white')
312
+ t = t.set_position(("center", 20)).set_duration(duration)
313
+ t = t.set_start(start_time)
314
+ return t
315
+
316
+ def convert_format_id_to_offset(id_list):
317
+ offset_list = []
318
+ current_id = id_list[0]
319
+ offset = 0
320
+ for i in range(len(id_list)):
321
+ if id_list[i] != current_id:
322
+ current_id = id_list[i]
323
+ offset = 0
324
+ offset_list.append(offset)
325
+ offset += 1
326
+ return offset_list
327
+
328
+
329
+ class Video2music:
330
+ def __init__(
331
+ self,
332
+ name="amaai-lab/video2music",
333
+ device="cuda:0",
334
+ cache_dir=None,
335
+ local_files_only=False,
336
+ ):
337
+ # path = snapshot_download(repo_id=name, cache_dir=cache_dir)
338
+
339
+ self.device = device
340
+
341
+ # self.model.device = device
342
+ # self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
343
+ # f"{path}/beats/microsoft-deberta-v3-large.pt"
344
+
345
+ # self.model_weights = f"{path}/saved_models/AMT/best_loss_weights.pickle"
346
+ # self.modelReg_weights = f"{path}/saved_models/AMT/best_rmse_weights.pickle"
347
+
348
+ self.model_weights = "saved_models/AMT/best_loss_weights.pickle"
349
+ self.modelReg_weights = "saved_models/AMT/best_rmse_weights.pickle"
350
+
351
+ self.total_vf_dim = 776
352
+ # 768 (sem) + 1 (mo) + 1 (scene) + 6 (emo)
353
+ self.max_seq_video = 300
354
+ self.max_seq_chord = 300
355
+
356
+ self.model = VideoMusicTransformer(n_layers=6, num_heads=8,
357
+ d_model=512, dim_feedforward=1024,
358
+ max_sequence_midi=2048, max_sequence_video=300,
359
+ max_sequence_chord=300, total_vf_dim=self.total_vf_dim, rpr=RPR).to(device)
360
+
361
+ self.model.load_state_dict(torch.load(self.model_weights, map_location=device))
362
+ self.modelReg = VideoRegression(max_sequence_video=300, total_vf_dim=self.total_vf_dim, regModel= "bigru").to(device)
363
+ self.modelReg.load_state_dict(torch.load(self.modelReg_weights, map_location=device))
364
+
365
+ self.model.eval()
366
+ self.modelReg.eval()
367
+
368
+ self.SF2_FILE = "default_sound_font.sf2"
369
+
370
+ def generate(self, video, primer, key):
371
+
372
+ feature_dir = Path("./feature")
373
+ output_dir = Path("./output")
374
+ if feature_dir.exists():
375
+ shutil.rmtree(str(feature_dir))
376
+ if output_dir.exists():
377
+ shutil.rmtree(str(output_dir))
378
+
379
+ feature_dir.mkdir(parents=True)
380
+ output_dir.mkdir(parents=True)
381
+
382
+ frame_dir = feature_dir / "vevo_frame"
383
+
384
+ #video features
385
+ semantic_dir = feature_dir / "vevo_semantic"
386
+ emotion_dir = feature_dir / "vevo_emotion"
387
+ scene_dir = feature_dir / "vevo_scene"
388
+ scene_offset_dir = feature_dir / "vevo_scene_offset"
389
+ motion_dir = feature_dir / "vevo_motion"
390
+
391
+ frame_dir.mkdir(parents=True)
392
+ semantic_dir.mkdir(parents=True)
393
+ emotion_dir.mkdir(parents=True)
394
+ scene_dir.mkdir(parents=True)
395
+ scene_offset_dir.mkdir(parents=True)
396
+ motion_dir.mkdir(parents=True)
397
+
398
+ #music features
399
+ chord_dir = feature_dir / "vevo_chord"
400
+ loudness_dir = feature_dir / "vevo_loudness"
401
+ note_density_dir = feature_dir / "vevo_note_density"
402
+
403
+ chord_dir.mkdir(parents=True)
404
+ loudness_dir.mkdir(parents=True)
405
+ note_density_dir.mkdir(parents=True)
406
+
407
+ split_video_into_frames(video, frame_dir)
408
+ gen_semantic_feature(frame_dir, semantic_dir)
409
+ gen_emotion_feature(frame_dir, emotion_dir)
410
+ gen_scene_feature(video, scene_dir)
411
+ gen_scene_offset_feature(scene_dir, scene_offset_dir)
412
+ gen_motion_feature(video, motion_dir)
413
+
414
+ feature_scene_offset = get_scene_offset_feature(scene_offset_dir)
415
+ feature_motion = get_motion_feature(motion_dir)
416
+ feature_emotion = get_emotion_feature(emotion_dir)
417
+ feature_semantic = get_semantic_feature(semantic_dir)
418
+
419
+ # cuda
420
+ feature_scene_offset = feature_scene_offset.to(self.device)
421
+ feature_motion = feature_motion.to(self.device)
422
+ feature_emotion = feature_emotion.to(self.device)
423
+
424
+ feature_scene_offset = feature_scene_offset.unsqueeze(0)
425
+ feature_motion = feature_motion.unsqueeze(0)
426
+ feature_emotion = feature_emotion.unsqueeze(0)
427
+
428
+ feature_semantic = feature_semantic.to(self.device)
429
+ feature_semantic_list = []
430
+ feature_semantic = torch.unsqueeze(feature_semantic, 0)
431
+ feature_semantic_list.append( feature_semantic.to(self.device) )
432
+ #feature_semantic_list.append( feature_semantic )
433
+
434
+ if "major" in key:
435
+ feature_key = torch.tensor([0])
436
+ feature_key = feature_key.float()
437
+ elif "minor" in key:
438
+ feature_key = torch.tensor([1])
439
+ feature_key = feature_key.float()
440
+
441
+ feature_key = feature_key.to(self.device)
442
+
443
+ with open('dataset/vevo_meta/chord.json') as json_file:
444
+ chordDic = json.load(json_file)
445
+ with open('dataset/vevo_meta/chord_inv.json') as json_file:
446
+ chordInvDic = json.load(json_file)
447
+ with open('dataset/vevo_meta/chord_root.json') as json_file:
448
+ chordRootDic = json.load(json_file)
449
+ with open('dataset/vevo_meta/chord_attr.json') as json_file:
450
+ chordAttrDic = json.load(json_file)
451
+
452
+ if primer.strip() == "":
453
+ if "major" in key:
454
+ primer = "C"
455
+ else:
456
+ primer = "Am"
457
+
458
+ pChordList = primer.split(" ")
459
+
460
+ primerCID = []
461
+ primerCID_root = []
462
+ primerCID_attr = []
463
+
464
+ for pChord in pChordList:
465
+ if len(pChord) > 1:
466
+ if pChord[1] == "b":
467
+ pChord = flatsharpDic [ pChord[0:2] ] + pChord[2:]
468
+ type_idx = 0
469
+ if pChord[1] == "#":
470
+ pChord = pChord[0:2] + ":" + pChord[2:]
471
+ type_idx = 2
472
+ else:
473
+ pChord = pChord[0:1] + ":" + pChord[1:]
474
+ type_idx = 1
475
+ if pChord[type_idx+1:] == "m":
476
+ pChord = pChord[0:type_idx] + ":min"
477
+ if pChord[type_idx+1:] == "m6":
478
+ pChord = pChord[0:type_idx] + ":min6"
479
+ if pChord[type_idx+1:] == "m7":
480
+ pChord = pChord[0:type_idx] + ":min7"
481
+ if pChord[type_idx+1:] == "M6":
482
+ pChord = pChord[0:type_idx] + ":maj6"
483
+ if pChord[type_idx+1:] == "M7":
484
+ pChord = pChord[0:type_idx] + ":maj7"
485
+ if pChord[type_idx+1:] == "":
486
+ pChord = pChord[0:type_idx]
487
+
488
+ chordID = chordDic[pChord]
489
+ primerCID.append(chordID)
490
+
491
+ chord_arr = pChord.split(":")
492
+ if len(chord_arr) == 1:
493
+ chordRootID = chordRootDic[chord_arr[0]]
494
+ primerCID_root.append(chordRootID)
495
+ primerCID_attr.append(0)
496
+ elif len(chord_arr) == 2:
497
+ chordRootID = chordRootDic[chord_arr[0]]
498
+ chordAttrID = chordAttrDic[chord_arr[1]]
499
+ primerCID_root.append(chordRootID)
500
+ primerCID_attr.append(chordAttrID)
501
+
502
+ primerCID = np.array(primerCID)
503
+ primerCID = torch.from_numpy(primerCID)
504
+ primerCID = primerCID.to(torch.long)
505
+ primerCID = primerCID.to(self.device)
506
+
507
+ primerCID_root = np.array(primerCID_root)
508
+ primerCID_root = torch.from_numpy(primerCID_root)
509
+ primerCID_root = primerCID_root.to(torch.long)
510
+ primerCID_root = primerCID_root.to(self.device)
511
+
512
+ primerCID_attr = np.array(primerCID_attr)
513
+ primerCID_attr = torch.from_numpy(primerCID_attr)
514
+ primerCID_attr = primerCID_attr.to(torch.long)
515
+ primerCID_attr = primerCID_attr.to(self.device)
516
+
517
+ # self.model.eval()
518
+ # self.modelReg.eval()
519
+
520
+ with torch.set_grad_enabled(False):
521
+ rand_seq = self.model.generate(feature_semantic_list=feature_semantic_list,
522
+ feature_key=feature_key,
523
+ feature_scene_offset=feature_scene_offset,
524
+ feature_motion=feature_motion,
525
+ feature_emotion=feature_emotion,
526
+ primer = primerCID,
527
+ primer_root = primerCID_root,
528
+ primer_attr = primerCID_attr,
529
+ target_seq_length = 300,
530
+ beam=0,
531
+ max_conseq_N= max_conseq_N,
532
+ max_conseq_chord = max_conseq_chord)
533
+
534
+ y = self.modelReg(
535
+ feature_semantic_list,
536
+ feature_scene_offset,
537
+ feature_motion,
538
+ feature_emotion)
539
+
540
+ y = y.reshape(y.shape[0] * y.shape[1], -1)
541
+
542
+ y_note_density, y_loudness = torch.split(y, split_size_or_sections=1, dim=1)
543
+ y_note_density_np = y_note_density.cpu().numpy()
544
+ y_note_density_np = np.round(y_note_density_np).astype(int)
545
+ y_note_density_np = np.clip(y_note_density_np, 0, 40)
546
+
547
+ y_loudness_np = y_loudness.cpu().numpy()
548
+ y_loudness_np_lv = (y_loudness_np * 100).astype(int)
549
+ y_loudness_np_lv = np.clip(y_loudness_np_lv, 0, 50)
550
+ velolistExp = []
551
+ exponent = 0.3
552
+ for item in y_loudness_np_lv:
553
+ loudness = item[0]
554
+ velocity_exp = np.round(((loudness - min_loudness) / (max_loudness - min_loudness)) ** exponent * (max_velocity - min_velocity) + min_velocity)
555
+ velocity_exp = int(velocity_exp)
556
+ velolistExp.append(velocity_exp)
557
+
558
+ densitylist = []
559
+ for item in y_loudness_np_lv:
560
+ density = item[0]
561
+ if density <= 6:
562
+ densitylist.append(0)
563
+ elif density <= 12:
564
+ densitylist.append(1)
565
+ elif density <= 18:
566
+ densitylist.append(2)
567
+ elif density <= 24:
568
+ densitylist.append(3)
569
+ else:
570
+ densitylist.append(4)
571
+
572
+ # generated ChordID to ChordSymbol
573
+ chord_genlist = []
574
+ chordID_genlist= rand_seq[0].cpu().numpy()
575
+ for i in chordID_genlist:
576
+ chord_genlist.append(chordInvDic[str(i)])
577
+
578
+ chord_offsetlist = convert_format_id_to_offset(chord_genlist)
579
+ f_path_midi = output_dir / "output.mid"
580
+ f_path_flac = output_dir / "output.flac"
581
+ f_path_video_out = output_dir / "output.mp4"
582
+
583
+ # ChordSymbol to MIDI file with voicing
584
+ MIDI = MIDIFile(1)
585
+ MIDI.addTempo(0, 0, tempo)
586
+ midi_chords_orginal = []
587
+ for i, k in enumerate(chord_genlist):
588
+ k = k.replace(":", "")
589
+ if k == "N":
590
+ midi_chords_orginal.append([])
591
+ else:
592
+ midi_chords_orginal.append(Chord(k).getMIDI("c", 4))
593
+ midi_chords = voice(midi_chords_orginal)
594
+ trans = traspose_key_dic[key]
595
+
596
+ for i, chord in enumerate(midi_chords):
597
+ if densitylist[i] == 0:
598
+ if len(chord) >= 4:
599
+ if chord_offsetlist[i] % 2 == 0:
600
+ MIDI.addNote(0, 0, chord[0]+trans, i * duration + 0 , duration, velolistExp[i])
601
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 1 , duration, velolistExp[i])
602
+ else:
603
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 0 , duration, velolistExp[i])
604
+ MIDI.addNote(0, 0, chord[3]+trans, i * duration + 1 , duration, velolistExp[i])
605
+ elif densitylist[i] == 1:
606
+ if len(chord) >= 4:
607
+ if chord_offsetlist[i] % 2 == 0:
608
+ MIDI.addNote(0, 0, chord[0]+trans, i * duration + 0 , duration, velolistExp[i])
609
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.5 , duration, velolistExp[i])
610
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1 , duration, velolistExp[i])
611
+ else:
612
+ MIDI.addNote(0, 0, chord[3]+trans, i * duration + 0 , duration, velolistExp[i])
613
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.5 , duration, velolistExp[i])
614
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1 , duration, velolistExp[i])
615
+ elif densitylist[i] == 2:
616
+ if len(chord) >= 4:
617
+ if chord_offsetlist[i] % 2 == 0:
618
+ MIDI.addNote(0, 0, chord[0]+trans, i * duration + 0 , duration, velolistExp[i])
619
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.5 , duration, velolistExp[i])
620
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1 , duration, velolistExp[i])
621
+ MIDI.addNote(0, 0, chord[3]+trans, i * duration + 1.5 , duration, velolistExp[i])
622
+ else:
623
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 0 , duration, velolistExp[i])
624
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.5 , duration, velolistExp[i])
625
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1 , duration, velolistExp[i])
626
+ MIDI.addNote(0, 0, chord[3]+trans, i * duration + 1.5 , duration, velolistExp[i])
627
+ elif densitylist[i] == 3:
628
+ if len(chord) >= 4:
629
+ if chord_offsetlist[i] % 2 == 0:
630
+ MIDI.addNote(0, 0, chord[0]+trans, i * duration + 0 , duration, velolistExp[i])
631
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.25 , duration, velolistExp[i])
632
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 0.5 , duration, velolistExp[i])
633
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.75 , duration, velolistExp[i])
634
+ MIDI.addNote(0, 0, chord[3]+trans, i * duration + 1 , duration, velolistExp[i])
635
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1.5 , duration, velolistExp[i])
636
+ else:
637
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0 , duration, velolistExp[i])
638
+ MIDI.addNote(0, 0, chord[0]+trans, i * duration + 0.25 , duration, velolistExp[i])
639
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.5 , duration, velolistExp[i])
640
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 0.75 , duration, velolistExp[i])
641
+ MIDI.addNote(0, 0, chord[3]+trans, i * duration + 1 , duration, velolistExp[i])
642
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1.5 , duration, velolistExp[i])
643
+ elif densitylist[i] == 4:
644
+ if len(chord) >= 4:
645
+ if chord_offsetlist[i] % 2 == 0:
646
+ MIDI.addNote(0, 0, chord[0]+trans, i * duration + 0 , duration, velolistExp[i])
647
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.25 , duration, velolistExp[i])
648
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 0.5 , duration, velolistExp[i])
649
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.75 , duration, velolistExp[i])
650
+ MIDI.addNote(0, 0, chord[3]+trans, i * duration + 1 , duration, velolistExp[i])
651
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1.25 , duration, velolistExp[i])
652
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 1.5 , duration, velolistExp[i])
653
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1.75 , duration, velolistExp[i])
654
+ else:
655
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0 , duration, velolistExp[i])
656
+ MIDI.addNote(0, 0, chord[0]+trans, i * duration + 0.25 , duration, velolistExp[i])
657
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 0.5 , duration, velolistExp[i])
658
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 0.75 , duration, velolistExp[i])
659
+ MIDI.addNote(0, 0, chord[3]+trans, i * duration + 1 , duration, velolistExp[i])
660
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1.25 , duration, velolistExp[i])
661
+ MIDI.addNote(0, 0, chord[1]+trans, i * duration + 1.5 , duration, velolistExp[i])
662
+ MIDI.addNote(0, 0, chord[2]+trans, i * duration + 1.75 , duration, velolistExp[i])
663
+
664
+ with open(f_path_midi, "wb") as outputFile:
665
+ MIDI.writeFile(outputFile)
666
+
667
+ # Convert midi to audio (e.g., flac)
668
+ fs = FluidSynth(sound_font=self.SF2_FILE)
669
+ fs.midi_to_audio(str(f_path_midi), str(f_path_flac))
670
+
671
+ # Render generated music into input video
672
+ audio_mp = mp.AudioFileClip(str(f_path_flac))
673
+ video_mp = mp.VideoFileClip(str(video))
674
+
675
+ audio_mp = audio_mp.subclip(0, video_mp.duration )
676
+ final = video_mp.set_audio(audio_mp)
677
+
678
+ final.write_videofile(str(f_path_video_out),
679
+ codec='libx264',
680
+ audio_codec='aac',
681
+ temp_audiofile='temp-audio.m4a',
682
+ remove_temp=True
683
+ )
684
+ return Path(str(f_path_video_out))
685
+
686
+
687
+ # Initialize Mustango
688
+ if torch.cuda.is_available():
689
+ video2music = Video2music()
690
+ else:
691
+ video2music = Video2music(device="cpu")
692
+
693
+
694
+ def gradio_generate(input_video, input_primer, input_key):
695
+ output_filename = video2music.generate(input_video, input_primer, input_key)
696
+ return str(output_filename)
697
+
698
+
699
+ title="Video2Music: Suitable Music Generation from Videos using an Affective Multimodal Transformer model"
700
+ description_text = """
701
+ <p>
702
+ Generate background music using Video2Music by providing an input video.
703
+ <br/><br/> This is the demo for Video2Music: Suitable Music Generation from Videos using an Affective Multimodal Transformer model
704
+ <a href="https://arxiv.org/abs/2311.00968">Read our paper.</a>
705
+ <p/>
706
+ """
707
+ input_video = gr.Video(label="Input Video")
708
+ input_primer = gr.Textbox(label="Input Primer", value="C Am F G")
709
+ input_key = gr.Dropdown(choices=["C major", "A minor"], value="C major", label="Input Key")
710
+ output_video = gr.Video(label="Output Video")
711
+
712
+ css = '''
713
+ #duplicate-button {
714
+ margin: auto;
715
+ color: white;
716
+ background: #1565c0;
717
+ border-radius: 100vh;
718
+ }
719
+ '''
720
+
721
+ # Gradio interface
722
+ gr_interface = gr.Interface(
723
+ fn=gradio_generate,
724
+ inputs=[input_video, input_primer, input_key ],
725
+ outputs=[output_video],
726
+ description=description_text,
727
+ allow_flagging='never',
728
+ cache_examples=True,
729
+ )
730
+
731
+
732
+ # with gr.Blocks() as demo:
733
+ with gr.Blocks(css=css) as demo:
734
+ title=gr.HTML(f"<h1><center>{title}</center></h1>")
735
+ gr_interface.render()
736
+
737
+ #demo.queue()
738
+ # demo.launch(debug=True)
739
+
740
+ demo.queue().launch()
741
 
 
 
dataset/README.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MuVi-Sync Dataset
2
+
3
+ - Dataset (MuVi-Sync)
4
+ * MuVi-Sync (features) [(Link)](https://zenodo.org/records/10057093)
5
+ * MuVi-Sync (original video) [(Link)](https://zenodo.org/records/10050294)
6
+
7
+ ## Overview
8
+ Welcome to the MuVi-Sync dataset! This collection provides a rich array of features for both music and video elements. Here's a breakdown of the directory structure:
9
+
10
+ ### Music Features
11
+ - **vevo_chord:** Chord feature data
12
+ - **vevo_note_density:** Note density feature data
13
+ - **vevo_loudness:** Loudness feature data
14
+
15
+ ### Video Features
16
+ - **vevo_scene_offset:** Scene offset feature data
17
+ - **vevo_emotion:** Emotion feature data
18
+ - *5c_l14p:* 5 emotion categories (exciting, fearful, tense, sad, relaxing)
19
+ - *6c_l14p:* 6 emotion categories (exciting, fearful, tense, sad, relaxing, neutral)
20
+ - **vevo_semantic:** Semantic feature
21
+ - **vevo_motion:** Motion feature
22
+
23
+ ### Others
24
+ - **vevo_meta:**
25
+ - *idlist.txt:* List of features, titles, and YouTube IDs
26
+ - **vevo:** Original video files (.mp4)
27
+
28
+ Explore and utilize this dataset for innovative research and applications.
29
+
30
+ For more details, refer to our [GitHub repository](https://github.com/AMAAI-Lab/Video2Music).
31
+
dataset/__pycache__/vevo_dataset.cpython-37.pyc ADDED
Binary file (14.6 kB). View file
 
dataset/vevo_dataset.py ADDED
@@ -0,0 +1,720 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pickle
3
+ import random
4
+ import torch
5
+ import torch.nn as nn
6
+ import numpy as np
7
+
8
+ from torch.utils.data import Dataset
9
+ from utilities.constants import *
10
+ from utilities.device import cpu_device
11
+ from utilities.device import get_device
12
+
13
+ import json
14
+
15
+ SEQUENCE_START = 0
16
+
17
+ class VevoDataset(Dataset):
18
+ def __init__(self, dataset_root = "./dataset/", split="train", split_ver="v1", vis_models="2d/clip_l14p", emo_model="6c_l14p", max_seq_chord=300, max_seq_video=300, random_seq=True, is_video = True):
19
+
20
+ self.dataset_root = dataset_root
21
+
22
+ self.vevo_chord_root = os.path.join( dataset_root, "vevo_chord", "lab_v2_norm", "all")
23
+ self.vevo_emotion_root = os.path.join( dataset_root, "vevo_emotion", emo_model, "all")
24
+ self.vevo_motion_root = os.path.join( dataset_root, "vevo_motion", "all")
25
+ self.vevo_scene_offset_root = os.path.join( dataset_root, "vevo_scene_offset", "all")
26
+ self.vevo_meta_split_path = os.path.join( dataset_root, "vevo_meta", "split", split_ver, split + ".txt")
27
+
28
+ self.vevo_loudness_root = os.path.join( dataset_root, "vevo_loudness", "all")
29
+ self.vevo_note_density_root = os.path.join( dataset_root, "vevo_note_density", "all")
30
+
31
+ self.max_seq_video = max_seq_video
32
+ self.max_seq_chord = max_seq_chord
33
+ self.random_seq = random_seq
34
+ self.is_video = is_video
35
+
36
+ self.vis_models_arr = vis_models.split(" ")
37
+ self.vevo_semantic_root_list = []
38
+ self.id_list = []
39
+
40
+ self.emo_model = emo_model
41
+
42
+ if IS_VIDEO:
43
+ for i in range( len(self.vis_models_arr) ):
44
+ p1 = self.vis_models_arr[i].split("/")[0]
45
+ p2 = self.vis_models_arr[i].split("/")[1]
46
+ vevo_semantic_root = os.path.join(dataset_root, "vevo_semantic" , "all" , p1, p2)
47
+ self.vevo_semantic_root_list.append( vevo_semantic_root )
48
+
49
+ with open( self.vevo_meta_split_path ) as f:
50
+ for line in f:
51
+ self.id_list.append(line.strip())
52
+
53
+ self.data_files_chord = []
54
+ self.data_files_emotion = []
55
+ self.data_files_motion = []
56
+ self.data_files_scene_offset = []
57
+ self.data_files_semantic_list = []
58
+
59
+ self.data_files_loudness = []
60
+ self.data_files_note_density = []
61
+
62
+ for i in range(len(self.vis_models_arr)):
63
+ self.data_files_semantic_list.append([])
64
+
65
+ for fid in self.id_list:
66
+ fpath_chord = os.path.join( self.vevo_chord_root, fid + ".lab" )
67
+ fpath_emotion = os.path.join( self.vevo_emotion_root, fid + ".lab" )
68
+ fpath_motion = os.path.join( self.vevo_motion_root, fid + ".lab" )
69
+ fpath_scene_offset = os.path.join( self.vevo_scene_offset_root, fid + ".lab" )
70
+
71
+ fpath_loudness = os.path.join( self.vevo_loudness_root, fid + ".lab" )
72
+ fpath_note_density = os.path.join( self.vevo_note_density_root, fid + ".lab" )
73
+
74
+ fpath_semantic_list = []
75
+ for vevo_semantic_root in self.vevo_semantic_root_list:
76
+ fpath_semantic = os.path.join( vevo_semantic_root, fid + ".npy" )
77
+ fpath_semantic_list.append(fpath_semantic)
78
+
79
+ checkFile_semantic = True
80
+ for fpath_semantic in fpath_semantic_list:
81
+ if not os.path.exists(fpath_semantic):
82
+ checkFile_semantic = False
83
+
84
+ checkFile_chord = os.path.exists(fpath_chord)
85
+ checkFile_emotion = os.path.exists(fpath_emotion)
86
+ checkFile_motion = os.path.exists(fpath_motion)
87
+ checkFile_scene_offset = os.path.exists(fpath_scene_offset)
88
+
89
+ checkFile_loudness = os.path.exists(fpath_loudness)
90
+ checkFile_note_density = os.path.exists(fpath_note_density)
91
+
92
+ if checkFile_chord and checkFile_emotion and checkFile_motion \
93
+ and checkFile_scene_offset and checkFile_semantic and checkFile_loudness and checkFile_note_density :
94
+
95
+ self.data_files_chord.append(fpath_chord)
96
+ self.data_files_emotion.append(fpath_emotion)
97
+ self.data_files_motion.append(fpath_motion)
98
+ self.data_files_scene_offset.append(fpath_scene_offset)
99
+
100
+ self.data_files_loudness.append(fpath_loudness)
101
+ self.data_files_note_density.append(fpath_note_density)
102
+
103
+ if IS_VIDEO:
104
+ for i in range(len(self.vis_models_arr)):
105
+ self.data_files_semantic_list[i].append( fpath_semantic_list[i] )
106
+
107
+ chordDicPath = os.path.join( dataset_root, "vevo_meta/chord.json")
108
+
109
+ chordRootDicPath = os.path.join( dataset_root, "vevo_meta/chord_root.json")
110
+ chordAttrDicPath = os.path.join( dataset_root, "vevo_meta/chord_attr.json")
111
+
112
+ with open(chordDicPath) as json_file:
113
+ self.chordDic = json.load(json_file)
114
+
115
+ with open(chordRootDicPath) as json_file:
116
+ self.chordRootDic = json.load(json_file)
117
+
118
+ with open(chordAttrDicPath) as json_file:
119
+ self.chordAttrDic = json.load(json_file)
120
+
121
+ def __len__(self):
122
+ return len(self.data_files_chord)
123
+
124
+ def __getitem__(self, idx):
125
+ #### ---- CHORD ----- ####
126
+ feature_chord = np.empty(self.max_seq_chord)
127
+ feature_chord.fill(CHORD_PAD)
128
+
129
+ feature_chordRoot = np.empty(self.max_seq_chord)
130
+ feature_chordRoot.fill(CHORD_ROOT_PAD)
131
+ feature_chordAttr = np.empty(self.max_seq_chord)
132
+ feature_chordAttr.fill(CHORD_ATTR_PAD)
133
+
134
+ key = ""
135
+ with open(self.data_files_chord[idx], encoding = 'utf-8') as f:
136
+ for line in f:
137
+ line = line.strip()
138
+ line_arr = line.split(" ")
139
+ if line_arr[0] == "key":
140
+ key = line_arr[1] + " "+ line_arr[2]
141
+ continue
142
+ time = line_arr[0]
143
+ time = int(time)
144
+ if time >= self.max_seq_chord:
145
+ break
146
+ chord = line_arr[1]
147
+ chordID = self.chordDic[chord]
148
+ feature_chord[time] = chordID
149
+ chord_arr = chord.split(":")
150
+
151
+ if len(chord_arr) == 1:
152
+ if chord_arr[0] == "N":
153
+ chordRootID = self.chordRootDic["N"]
154
+ chordAttrID = self.chordAttrDic["N"]
155
+ feature_chordRoot[time] = chordRootID
156
+ feature_chordAttr[time] = chordAttrID
157
+ else:
158
+ chordRootID = self.chordRootDic[chord_arr[0]]
159
+ feature_chordRoot[time] = chordRootID
160
+ feature_chordAttr[time] = 1
161
+ elif len(chord_arr) == 2:
162
+ chordRootID = self.chordRootDic[chord_arr[0]]
163
+ chordAttrID = self.chordAttrDic[chord_arr[1]]
164
+ feature_chordRoot[time] = chordRootID
165
+ feature_chordAttr[time] = chordAttrID
166
+
167
+ if "major" in key:
168
+ feature_key = torch.tensor([0])
169
+ else:
170
+ feature_key = torch.tensor([1])
171
+
172
+ feature_chord = torch.from_numpy(feature_chord)
173
+ feature_chord = feature_chord.to(torch.long)
174
+
175
+ feature_chordRoot = torch.from_numpy(feature_chordRoot)
176
+ feature_chordRoot = feature_chordRoot.to(torch.long)
177
+
178
+ feature_chordAttr = torch.from_numpy(feature_chordAttr)
179
+ feature_chordAttr = feature_chordAttr.to(torch.long)
180
+
181
+ feature_key = feature_key.float()
182
+
183
+ x = feature_chord[:self.max_seq_chord-1]
184
+ tgt = feature_chord[1:self.max_seq_chord]
185
+
186
+ x_root = feature_chordRoot[:self.max_seq_chord-1]
187
+ tgt_root = feature_chordRoot[1:self.max_seq_chord]
188
+ x_attr = feature_chordAttr[:self.max_seq_chord-1]
189
+ tgt_attr = feature_chordAttr[1:self.max_seq_chord]
190
+
191
+ if time < self.max_seq_chord:
192
+ tgt[time] = CHORD_END
193
+ tgt_root[time] = CHORD_ROOT_END
194
+ tgt_attr[time] = CHORD_ATTR_END
195
+
196
+ #### ---- SCENE OFFSET ----- ####
197
+ feature_scene_offset = np.empty(self.max_seq_video)
198
+ feature_scene_offset.fill(SCENE_OFFSET_PAD)
199
+ with open(self.data_files_scene_offset[idx], encoding = 'utf-8') as f:
200
+ for line in f:
201
+ line = line.strip()
202
+ line_arr = line.split(" ")
203
+ time = line_arr[0]
204
+ time = int(time)
205
+ if time >= self.max_seq_chord:
206
+ break
207
+ sceneID = line_arr[1]
208
+ feature_scene_offset[time] = int(sceneID)+1
209
+
210
+ feature_scene_offset = torch.from_numpy(feature_scene_offset)
211
+ feature_scene_offset = feature_scene_offset.to(torch.float32)
212
+
213
+ #### ---- MOTION ----- ####
214
+ feature_motion = np.empty(self.max_seq_video)
215
+ feature_motion.fill(MOTION_PAD)
216
+ with open(self.data_files_motion[idx], encoding = 'utf-8') as f:
217
+ for line in f:
218
+ line = line.strip()
219
+ line_arr = line.split(" ")
220
+ time = line_arr[0]
221
+ time = int(time)
222
+ if time >= self.max_seq_chord:
223
+ break
224
+ motion = line_arr[1]
225
+ feature_motion[time] = float(motion)
226
+
227
+ feature_motion = torch.from_numpy(feature_motion)
228
+ feature_motion = feature_motion.to(torch.float32)
229
+
230
+ #### ---- NOTE_DENSITY ----- ####
231
+ feature_note_density = np.empty(self.max_seq_video)
232
+ feature_note_density.fill(NOTE_DENSITY_PAD)
233
+ with open(self.data_files_note_density[idx], encoding = 'utf-8') as f:
234
+ for line in f:
235
+ line = line.strip()
236
+ line_arr = line.split(" ")
237
+ time = line_arr[0]
238
+ time = int(time)
239
+ if time >= self.max_seq_chord:
240
+ break
241
+ note_density = line_arr[1]
242
+ feature_note_density[time] = float(note_density)
243
+
244
+ feature_note_density = torch.from_numpy(feature_note_density)
245
+ feature_note_density = feature_note_density.to(torch.float32)
246
+
247
+ #### ---- LOUDNESS ----- ####
248
+ feature_loudness = np.empty(self.max_seq_video)
249
+ feature_loudness.fill(LOUDNESS_PAD)
250
+ with open(self.data_files_loudness[idx], encoding = 'utf-8') as f:
251
+ for line in f:
252
+ line = line.strip()
253
+ line_arr = line.split(" ")
254
+ time = line_arr[0]
255
+ time = int(time)
256
+ if time >= self.max_seq_chord:
257
+ break
258
+ loudness = line_arr[1]
259
+ feature_loudness[time] = float(loudness)
260
+
261
+ feature_loudness = torch.from_numpy(feature_loudness)
262
+ feature_loudness = feature_loudness.to(torch.float32)
263
+
264
+ #### ---- EMOTION ----- ####
265
+ if self.emo_model.startswith("6c"):
266
+ feature_emotion = np.empty( (self.max_seq_video, 6))
267
+ else:
268
+ feature_emotion = np.empty( (self.max_seq_video, 5))
269
+
270
+ feature_emotion.fill(EMOTION_PAD)
271
+ with open(self.data_files_emotion[idx], encoding = 'utf-8') as f:
272
+ for line in f:
273
+ line = line.strip()
274
+ line_arr = line.split(" ")
275
+ if line_arr[0] == "time":
276
+ continue
277
+ time = line_arr[0]
278
+ time = int(time)
279
+ if time >= self.max_seq_chord:
280
+ break
281
+
282
+ if len(line_arr) == 7:
283
+ emo1, emo2, emo3, emo4, emo5, emo6 = \
284
+ line_arr[1],line_arr[2],line_arr[3],line_arr[4],line_arr[5],line_arr[6]
285
+ emoList = [ float(emo1), float(emo2), float(emo3), float(emo4), float(emo5), float(emo6) ]
286
+ elif len(line_arr) == 6:
287
+ emo1, emo2, emo3, emo4, emo5 = \
288
+ line_arr[1],line_arr[2],line_arr[3],line_arr[4],line_arr[5]
289
+ emoList = [ float(emo1), float(emo2), float(emo3), float(emo4), float(emo5) ]
290
+
291
+ emoList = np.array(emoList)
292
+ feature_emotion[time] = emoList
293
+
294
+ feature_emotion = torch.from_numpy(feature_emotion)
295
+ feature_emotion = feature_emotion.to(torch.float32)
296
+
297
+ feature_emotion_argmax = torch.argmax(feature_emotion, dim=1)
298
+ _, max_prob_indices = torch.max(feature_emotion, dim=1)
299
+ max_prob_values = torch.gather(feature_emotion, dim=1, index=max_prob_indices.unsqueeze(1))
300
+ max_prob_values = max_prob_values.squeeze()
301
+
302
+ # -- emotion to chord
303
+ # maj dim sus4 min7 min sus2 aug dim7 maj6 hdim7 7 min6 maj7
304
+ # 0. extcing : [1,0,1,0,0,0,0,0,0,0,1,0,0]
305
+ # 1. fearful : [0,1,0,1,0,0,0,1,0,1,0,0,0]
306
+ # 2. tense : [0,1,1,1,0,0,0,0,0,0,1,0,0]
307
+ # 3. sad : [0,0,0,1,1,1,0,0,0,0,0,0,0]
308
+ # 4. relaxing: [1,0,0,0,0,0,0,0,1,0,0,0,1]
309
+ # 5. neutral : [0,0,0,0,0,0,0,0,0,0,0,0,0]
310
+
311
+ a0 = [0]+[1,0,1,0,0,0,0,0,0,0,1,0,0]*12+[0,0]
312
+ a1 = [0]+[0,1,0,1,0,0,0,1,0,1,0,0,0]*12+[0,0]
313
+ a2 = [0]+[0,1,1,1,0,0,0,0,0,0,1,0,0]*12+[0,0]
314
+ a3 = [0]+[0,0,0,1,1,1,0,0,0,0,0,0,0]*12+[0,0]
315
+ a4 = [0]+[1,0,0,0,0,0,0,0,1,0,0,0,1]*12+[0,0]
316
+ a5 = [0]+[0,0,0,0,0,0,0,0,0,0,0,0,0]*12+[0,0]
317
+
318
+ aend = [0]+[0,0,0,0,0,0,0,0,0,0,0,0,0]*12+[1,0]
319
+ apad = [0]+[0,0,0,0,0,0,0,0,0,0,0,0,0]*12+[0,1]
320
+
321
+ a0_tensor = torch.tensor(a0)
322
+ a1_tensor = torch.tensor(a1)
323
+ a2_tensor = torch.tensor(a2)
324
+ a3_tensor = torch.tensor(a3)
325
+ a4_tensor = torch.tensor(a4)
326
+ a5_tensor = torch.tensor(a5)
327
+
328
+ aend_tensor = torch.tensor(aend)
329
+ apad_tensor = torch.tensor(apad)
330
+
331
+ mapped_tensor = torch.zeros((300, 159))
332
+ for i, val in enumerate(feature_emotion_argmax):
333
+ if feature_chord[i] == CHORD_PAD:
334
+ mapped_tensor[i] = apad_tensor
335
+ elif feature_chord[i] == CHORD_END:
336
+ mapped_tensor[i] = aend_tensor
337
+ elif val == 0:
338
+ mapped_tensor[i] = a0_tensor
339
+ elif val == 1:
340
+ mapped_tensor[i] = a1_tensor
341
+ elif val == 2:
342
+ mapped_tensor[i] = a2_tensor
343
+ elif val == 3:
344
+ mapped_tensor[i] = a3_tensor
345
+ elif val == 4:
346
+ mapped_tensor[i] = a4_tensor
347
+ elif val == 5:
348
+ mapped_tensor[i] = a5_tensor
349
+
350
+ # feature emotion : [1, 300, 6]
351
+ # y : [299, 159]
352
+ # tgt : [299]
353
+ # tgt_emo : [299, 159]
354
+ # tgt_emo_prob : [299]
355
+
356
+ tgt_emotion = mapped_tensor[1:]
357
+ tgt_emotion_prob = max_prob_values[1:]
358
+
359
+ feature_semantic_list = []
360
+ if self.is_video:
361
+ for i in range( len(self.vis_models_arr) ):
362
+ video_feature = np.load(self.data_files_semantic_list[i][idx])
363
+ dim_vf = video_feature.shape[1] # 2048
364
+ video_feature_tensor = torch.from_numpy( video_feature )
365
+
366
+ feature_semantic = torch.full((self.max_seq_video, dim_vf,), SEMANTIC_PAD , dtype=torch.float32, device=cpu_device())
367
+ if(video_feature_tensor.shape[0] < self.max_seq_video):
368
+ feature_semantic[:video_feature_tensor.shape[0]] = video_feature_tensor
369
+ else:
370
+ feature_semantic = video_feature_tensor[:self.max_seq_video]
371
+ feature_semantic_list.append(feature_semantic)
372
+
373
+ return { "x":x,
374
+ "tgt":tgt,
375
+ "x_root":x_root,
376
+ "tgt_root":tgt_root,
377
+ "x_attr":x_attr,
378
+ "tgt_attr":tgt_attr,
379
+ "semanticList": feature_semantic_list,
380
+ "key": feature_key,
381
+ "scene_offset": feature_scene_offset,
382
+ "motion": feature_motion,
383
+ "emotion": feature_emotion,
384
+ "tgt_emotion" : tgt_emotion,
385
+ "tgt_emotion_prob" : tgt_emotion_prob,
386
+ "note_density" : feature_note_density,
387
+ "loudness" : feature_loudness
388
+ }
389
+
390
+ def create_vevo_datasets(dataset_root = "./dataset", max_seq_chord=300, max_seq_video=300, vis_models="2d/clip_l14p", emo_model="6c_l14p", split_ver="v1", random_seq=True, is_video=True):
391
+
392
+ train_dataset = VevoDataset(
393
+ dataset_root = dataset_root, split="train", split_ver=split_ver,
394
+ vis_models=vis_models, emo_model =emo_model, max_seq_chord=max_seq_chord, max_seq_video=max_seq_video,
395
+ random_seq=random_seq, is_video = is_video )
396
+
397
+ val_dataset = VevoDataset(
398
+ dataset_root = dataset_root, split="val", split_ver=split_ver,
399
+ vis_models=vis_models, emo_model =emo_model, max_seq_chord=max_seq_chord, max_seq_video=max_seq_video,
400
+ random_seq=random_seq, is_video = is_video )
401
+
402
+ test_dataset = VevoDataset(
403
+ dataset_root = dataset_root, split="test", split_ver=split_ver,
404
+ vis_models=vis_models, emo_model =emo_model, max_seq_chord=max_seq_chord, max_seq_video=max_seq_video,
405
+ random_seq=random_seq, is_video = is_video )
406
+
407
+ return train_dataset, val_dataset, test_dataset
408
+
409
+ def compute_vevo_accuracy(out, tgt):
410
+ softmax = nn.Softmax(dim=-1)
411
+ out = torch.argmax(softmax(out), dim=-1)
412
+
413
+ out = out.flatten()
414
+ tgt = tgt.flatten()
415
+
416
+ mask = (tgt != CHORD_PAD)
417
+
418
+ out = out[mask]
419
+ tgt = tgt[mask]
420
+
421
+ if(len(tgt) == 0):
422
+ return 1.0
423
+
424
+ num_right = (out == tgt)
425
+ num_right = torch.sum(num_right).type(TORCH_FLOAT)
426
+
427
+ acc = num_right / len(tgt)
428
+
429
+ return acc
430
+
431
+ def compute_hits_k(out, tgt, k):
432
+ softmax = nn.Softmax(dim=-1)
433
+ out = softmax(out)
434
+ _, topk_indices = torch.topk(out, k, dim=-1) # Get the indices of top-k values
435
+
436
+ tgt = tgt.flatten()
437
+
438
+ topk_indices = torch.squeeze(topk_indices, dim = 0)
439
+
440
+ num_right = 0
441
+ pt = 0
442
+ for i, tlist in enumerate(topk_indices):
443
+ if tgt[i] == CHORD_PAD:
444
+ num_right += 0
445
+ else:
446
+ pt += 1
447
+ if tgt[i].item() in tlist:
448
+ num_right += 1
449
+
450
+ # Empty
451
+ if len(tgt) == 0:
452
+ return 1.0
453
+
454
+ num_right = torch.tensor(num_right, dtype=torch.float32)
455
+ hitk = num_right / pt
456
+
457
+ return hitk
458
+
459
+ def compute_hits_k_root_attr(out_root, out_attr, tgt, k):
460
+ softmax = nn.Softmax(dim=-1)
461
+ out_root = softmax(out_root)
462
+ out_attr = softmax(out_attr)
463
+
464
+ tensor_shape = torch.Size([1, 299, 159])
465
+ out = torch.zeros(tensor_shape)
466
+ for i in range(out.shape[-1]):
467
+ if i == 0 :
468
+ out[0, :, i] = out_root[0, :, 0] * out_attr[0, :, 0]
469
+ elif i == 157:
470
+ out[0, :, i] = out_root[0, :, 13] * out_attr[0, :, 14]
471
+ elif i == 158:
472
+ out[0, :, i] = out_root[0, :, 14] * out_attr[0, :, 15]
473
+ else:
474
+ rootindex = int( (i-1)/13 ) + 1
475
+ attrindex = (i-1)%13 + 1
476
+ out[0, :, i] = out_root[0, :, rootindex] * out_attr[0, :, attrindex]
477
+
478
+ out = softmax(out)
479
+ _, topk_indices = torch.topk(out, k, dim=-1) # Get the indices of top-k values
480
+
481
+ tgt = tgt.flatten()
482
+
483
+ topk_indices = torch.squeeze(topk_indices, dim = 0)
484
+
485
+ num_right = 0
486
+ pt = 0
487
+ for i, tlist in enumerate(topk_indices):
488
+ if tgt[i] == CHORD_PAD:
489
+ num_right += 0
490
+ else:
491
+ pt += 1
492
+ if tgt[i].item() in tlist:
493
+ num_right += 1
494
+
495
+ if len(tgt) == 0:
496
+ return 1.0
497
+
498
+ num_right = torch.tensor(num_right, dtype=torch.float32)
499
+ hitk = num_right / pt
500
+
501
+ return hitk
502
+
503
+ def compute_vevo_correspondence(out, tgt, tgt_emotion, tgt_emotion_prob, emotion_threshold):
504
+
505
+ tgt_emotion = tgt_emotion.squeeze()
506
+ tgt_emotion_prob = tgt_emotion_prob.squeeze()
507
+
508
+ dataset_root = "./dataset/"
509
+ chordRootInvDicPath = os.path.join( dataset_root, "vevo_meta/chord_root_inv.json")
510
+ chordAttrInvDicPath = os.path.join( dataset_root, "vevo_meta/chord_attr_inv.json")
511
+ chordAttrDicPath = os.path.join( dataset_root, "vevo_meta/chord_attr.json")
512
+
513
+ chordDicPath = os.path.join( dataset_root, "vevo_meta/chord.json")
514
+ chordInvDicPath = os.path.join( dataset_root, "vevo_meta/chord_inv.json")
515
+
516
+ with open(chordRootInvDicPath) as json_file:
517
+ chordRootInvDic = json.load(json_file)
518
+ with open(chordAttrDicPath) as json_file:
519
+ chordAttrDic = json.load(json_file)
520
+ with open(chordAttrInvDicPath) as json_file:
521
+ chordAttrInvDic = json.load(json_file)
522
+ with open(chordDicPath) as json_file:
523
+ chordDic = json.load(json_file)
524
+ with open(chordInvDicPath) as json_file:
525
+ chordInvDic = json.load(json_file)
526
+
527
+ softmax = nn.Softmax(dim=-1)
528
+ out = torch.argmax(softmax(out), dim=-1)
529
+ out = out.flatten()
530
+
531
+ tgt = tgt.flatten()
532
+
533
+ num_right = 0
534
+ tgt_emotion_quality = tgt_emotion[:, 0:14]
535
+ pt = 0
536
+ for i, out_element in enumerate( out ):
537
+
538
+ all_zeros = torch.all(tgt_emotion_quality[i] == 0)
539
+ if tgt_emotion[i][-1] == 1 or all_zeros or tgt_emotion_prob[i] < emotion_threshold:
540
+ num_right += 0
541
+ else:
542
+ pt += 1
543
+ if out_element.item() != CHORD_END and out_element.item() != CHORD_PAD:
544
+ gen_chord = chordInvDic[ str( out_element.item() ) ]
545
+
546
+ chord_arr = gen_chord.split(":")
547
+ if len(chord_arr) == 1:
548
+ out_quality = 1
549
+ elif len(chord_arr) == 2:
550
+ chordAttrID = chordAttrDic[chord_arr[1]]
551
+ out_quality = chordAttrID # 0:N, 1:maj ... 13:maj7
552
+
553
+ if tgt_emotion_quality[i][out_quality] == 1:
554
+ num_right += 1
555
+
556
+
557
+ if(len(tgt_emotion) == 0):
558
+ return 1.0
559
+
560
+ if(pt == 0):
561
+ return -1
562
+
563
+ num_right = torch.tensor(num_right, dtype=torch.float32)
564
+ acc = num_right / pt
565
+
566
+ return acc
567
+
568
+ def compute_vevo_correspondence_root_attr(y_root, y_attr, tgt, tgt_emotion, tgt_emotion_prob, emotion_threshold):
569
+
570
+ tgt_emotion = tgt_emotion.squeeze()
571
+ tgt_emotion_prob = tgt_emotion_prob.squeeze()
572
+
573
+ dataset_root = "./dataset/"
574
+ chordRootInvDicPath = os.path.join( dataset_root, "vevo_meta/chord_root_inv.json")
575
+ chordAttrInvDicPath = os.path.join( dataset_root, "vevo_meta/chord_attr_inv.json")
576
+ chordAttrDicPath = os.path.join( dataset_root, "vevo_meta/chord_attr.json")
577
+
578
+ chordDicPath = os.path.join( dataset_root, "vevo_meta/chord.json")
579
+ chordInvDicPath = os.path.join( dataset_root, "vevo_meta/chord_inv.json")
580
+
581
+ with open(chordRootInvDicPath) as json_file:
582
+ chordRootInvDic = json.load(json_file)
583
+ with open(chordAttrDicPath) as json_file:
584
+ chordAttrDic = json.load(json_file)
585
+ with open(chordAttrInvDicPath) as json_file:
586
+ chordAttrInvDic = json.load(json_file)
587
+ with open(chordDicPath) as json_file:
588
+ chordDic = json.load(json_file)
589
+ with open(chordInvDicPath) as json_file:
590
+ chordInvDic = json.load(json_file)
591
+
592
+ softmax = nn.Softmax(dim=-1)
593
+
594
+ y_root = torch.argmax(softmax(y_root), dim=-1)
595
+ y_attr = torch.argmax(softmax(y_attr), dim=-1)
596
+
597
+ y_root = y_root.flatten()
598
+ y_attr = y_attr.flatten()
599
+
600
+ tgt = tgt.flatten()
601
+ y = np.empty( len(tgt) )
602
+
603
+ y.fill(CHORD_PAD)
604
+
605
+ for i in range(len(tgt)):
606
+ if y_root[i].item() == CHORD_ROOT_PAD or y_attr[i].item() == CHORD_ATTR_PAD:
607
+ y[i] = CHORD_PAD
608
+ elif y_root[i].item() == CHORD_ROOT_END or y_attr[i].item() == CHORD_ATTR_END:
609
+ y[i] = CHORD_END
610
+ else:
611
+ chordRoot = chordRootInvDic[str(y_root[i].item())]
612
+ chordAttr = chordAttrInvDic[str(y_attr[i].item())]
613
+ if chordRoot == "N":
614
+ y[i] = 0
615
+ else:
616
+ if chordAttr == "N" or chordAttr == "maj":
617
+ y[i] = chordDic[chordRoot]
618
+ else:
619
+ chord = chordRoot + ":" + chordAttr
620
+ y[i] = chordDic[chord]
621
+
622
+ y = torch.from_numpy(y)
623
+ y = y.to(torch.long)
624
+ y = y.to(get_device())
625
+ y = y.flatten()
626
+
627
+ num_right = 0
628
+ tgt_emotion_quality = tgt_emotion[:, 0:14]
629
+ pt = 0
630
+ for i, y_element in enumerate( y ):
631
+ all_zeros = torch.all(tgt_emotion_quality[i] == 0)
632
+ if tgt_emotion[i][-1] == 1 or all_zeros or tgt_emotion_prob[i] < emotion_threshold:
633
+ num_right += 0
634
+ else:
635
+ pt += 1
636
+ if y_element.item() != CHORD_END and y_element.item() != CHORD_PAD:
637
+ gen_chord = chordInvDic[ str( y_element.item() ) ]
638
+ chord_arr = gen_chord.split(":")
639
+ if len(chord_arr) == 1:
640
+ y_quality = 1
641
+ elif len(chord_arr) == 2:
642
+ chordAttrID = chordAttrDic[chord_arr[1]]
643
+ y_quality = chordAttrID # 0:N, 1:maj ... 13:maj7
644
+
645
+ if tgt_emotion_quality[i][y_quality] == 1:
646
+ num_right += 1
647
+
648
+ if(len(tgt_emotion) == 0):
649
+ return 1.0
650
+
651
+ if(pt == 0):
652
+ return -1
653
+
654
+ num_right = torch.tensor(num_right, dtype=torch.float32)
655
+ acc = num_right / pt
656
+ return acc
657
+
658
+ def compute_vevo_accuracy_root_attr(y_root, y_attr, tgt):
659
+
660
+ dataset_root = "./dataset/"
661
+ chordRootInvDicPath = os.path.join( dataset_root, "vevo_meta/chord_root_inv.json")
662
+ chordAttrInvDicPath = os.path.join( dataset_root, "vevo_meta/chord_attr_inv.json")
663
+ chordDicPath = os.path.join( dataset_root, "vevo_meta/chord.json")
664
+
665
+ with open(chordRootInvDicPath) as json_file:
666
+ chordRootInvDic = json.load(json_file)
667
+ with open(chordAttrInvDicPath) as json_file:
668
+ chordAttrInvDic = json.load(json_file)
669
+ with open(chordDicPath) as json_file:
670
+ chordDic = json.load(json_file)
671
+
672
+ softmax = nn.Softmax(dim=-1)
673
+
674
+ y_root = torch.argmax(softmax(y_root), dim=-1)
675
+ y_attr = torch.argmax(softmax(y_attr), dim=-1)
676
+
677
+ y_root = y_root.flatten()
678
+ y_attr = y_attr.flatten()
679
+
680
+ tgt = tgt.flatten()
681
+
682
+ mask = (tgt != CHORD_PAD)
683
+ y = np.empty( len(tgt) )
684
+ y.fill(CHORD_PAD)
685
+
686
+ for i in range(len(tgt)):
687
+ if y_root[i].item() == CHORD_ROOT_PAD or y_attr[i].item() == CHORD_ATTR_PAD:
688
+ y[i] = CHORD_PAD
689
+ elif y_root[i].item() == CHORD_ROOT_END or y_attr[i].item() == CHORD_ATTR_END:
690
+ y[i] = CHORD_END
691
+ else:
692
+ chordRoot = chordRootInvDic[str(y_root[i].item())]
693
+ chordAttr = chordAttrInvDic[str(y_attr[i].item())]
694
+ if chordRoot == "N":
695
+ y[i] = 0
696
+ else:
697
+ if chordAttr == "N" or chordAttr == "maj":
698
+ y[i] = chordDic[chordRoot]
699
+ else:
700
+ chord = chordRoot + ":" + chordAttr
701
+ y[i] = chordDic[chord]
702
+
703
+ y = torch.from_numpy(y)
704
+ y = y.to(torch.long)
705
+ y = y.to(get_device())
706
+
707
+ y = y[mask]
708
+ tgt = tgt[mask]
709
+
710
+ # Empty
711
+ if(len(tgt) == 0):
712
+ return 1.0
713
+
714
+ num_right = (y == tgt)
715
+ num_right = torch.sum(num_right).type(TORCH_FLOAT)
716
+
717
+ acc = num_right / len(tgt)
718
+
719
+ return acc
720
+
dataset/vevo_meta/chord.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"N": 0, "C": 1, "C:dim": 2, "C:sus4": 3, "C:min7": 4, "C:min": 5, "C:sus2": 6, "C:aug": 7, "C:dim7": 8, "C:maj6": 9, "C:hdim7": 10, "C:7": 11, "C:min6": 12, "C:maj7": 13, "C#": 14, "C#:dim": 15, "C#:sus4": 16, "C#:min7": 17, "C#:min": 18, "C#:sus2": 19, "C#:aug": 20, "C#:dim7": 21, "C#:maj6": 22, "C#:hdim7": 23, "C#:7": 24, "C#:min6": 25, "C#:maj7": 26, "D": 27, "D:dim": 28, "D:sus4": 29, "D:min7": 30, "D:min": 31, "D:sus2": 32, "D:aug": 33, "D:dim7": 34, "D:maj6": 35, "D:hdim7": 36, "D:7": 37, "D:min6": 38, "D:maj7": 39, "D#": 40, "D#:dim": 41, "D#:sus4": 42, "D#:min7": 43, "D#:min": 44, "D#:sus2": 45, "D#:aug": 46, "D#:dim7": 47, "D#:maj6": 48, "D#:hdim7": 49, "D#:7": 50, "D#:min6": 51, "D#:maj7": 52, "E": 53, "E:dim": 54, "E:sus4": 55, "E:min7": 56, "E:min": 57, "E:sus2": 58, "E:aug": 59, "E:dim7": 60, "E:maj6": 61, "E:hdim7": 62, "E:7": 63, "E:min6": 64, "E:maj7": 65, "F": 66, "F:dim": 67, "F:sus4": 68, "F:min7": 69, "F:min": 70, "F:sus2": 71, "F:aug": 72, "F:dim7": 73, "F:maj6": 74, "F:hdim7": 75, "F:7": 76, "F:min6": 77, "F:maj7": 78, "F#": 79, "F#:dim": 80, "F#:sus4": 81, "F#:min7": 82, "F#:min": 83, "F#:sus2": 84, "F#:aug": 85, "F#:dim7": 86, "F#:maj6": 87, "F#:hdim7": 88, "F#:7": 89, "F#:min6": 90, "F#:maj7": 91, "G": 92, "G:dim": 93, "G:sus4": 94, "G:min7": 95, "G:min": 96, "G:sus2": 97, "G:aug": 98, "G:dim7": 99, "G:maj6": 100, "G:hdim7": 101, "G:7": 102, "G:min6": 103, "G:maj7": 104, "G#": 105, "G#:dim": 106, "G#:sus4": 107, "G#:min7": 108, "G#:min": 109, "G#:sus2": 110, "G#:aug": 111, "G#:dim7": 112, "G#:maj6": 113, "G#:hdim7": 114, "G#:7": 115, "G#:min6": 116, "G#:maj7": 117, "A": 118, "A:dim": 119, "A:sus4": 120, "A:min7": 121, "A:min": 122, "A:sus2": 123, "A:aug": 124, "A:dim7": 125, "A:maj6": 126, "A:hdim7": 127, "A:7": 128, "A:min6": 129, "A:maj7": 130, "A#": 131, "A#:dim": 132, "A#:sus4": 133, "A#:min7": 134, "A#:min": 135, "A#:sus2": 136, "A#:aug": 137, "A#:dim7": 138, "A#:maj6": 139, "A#:hdim7": 140, "A#:7": 141, "A#:min6": 142, "A#:maj7": 143, "B": 144, "B:dim": 145, "B:sus4": 146, "B:min7": 147, "B:min": 148, "B:sus2": 149, "B:aug": 150, "B:dim7": 151, "B:maj6": 152, "B:hdim7": 153, "B:7": 154, "B:min6": 155, "B:maj7": 156}
dataset/vevo_meta/chord_attr.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"N": 0, "maj": 1, "dim": 2, "sus4": 3, "min7": 4, "min": 5, "sus2": 6, "aug": 7, "dim7": 8, "maj6": 9, "hdim7": 10, "7": 11, "min6": 12, "maj7": 13}
dataset/vevo_meta/chord_attr_inv.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "0": "N",
3
+ "1": "maj",
4
+ "2": "dim",
5
+ "3": "sus4",
6
+ "4": "min7",
7
+ "5": "min",
8
+ "6": "sus2",
9
+ "7": "aug",
10
+ "8": "dim7",
11
+ "9": "maj6",
12
+ "10": "hdim7",
13
+ "11": "7",
14
+ "12": "min6",
15
+ "13": "maj7"
16
+ }
dataset/vevo_meta/chord_inv.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"0": "N", "1": "C", "2": "C:dim", "3": "C:sus4", "4": "C:min7", "5": "C:min", "6": "C:sus2", "7": "C:aug", "8": "C:dim7", "9": "C:maj6", "10": "C:hdim7", "11": "C:7", "12": "C:min6", "13": "C:maj7", "14": "C#", "15": "C#:dim", "16": "C#:sus4", "17": "C#:min7", "18": "C#:min", "19": "C#:sus2", "20": "C#:aug", "21": "C#:dim7", "22": "C#:maj6", "23": "C#:hdim7", "24": "C#:7", "25": "C#:min6", "26": "C#:maj7", "27": "D", "28": "D:dim", "29": "D:sus4", "30": "D:min7", "31": "D:min", "32": "D:sus2", "33": "D:aug", "34": "D:dim7", "35": "D:maj6", "36": "D:hdim7", "37": "D:7", "38": "D:min6", "39": "D:maj7", "40": "D#", "41": "D#:dim", "42": "D#:sus4", "43": "D#:min7", "44": "D#:min", "45": "D#:sus2", "46": "D#:aug", "47": "D#:dim7", "48": "D#:maj6", "49": "D#:hdim7", "50": "D#:7", "51": "D#:min6", "52": "D#:maj7", "53": "E", "54": "E:dim", "55": "E:sus4", "56": "E:min7", "57": "E:min", "58": "E:sus2", "59": "E:aug", "60": "E:dim7", "61": "E:maj6", "62": "E:hdim7", "63": "E:7", "64": "E:min6", "65": "E:maj7", "66": "F", "67": "F:dim", "68": "F:sus4", "69": "F:min7", "70": "F:min", "71": "F:sus2", "72": "F:aug", "73": "F:dim7", "74": "F:maj6", "75": "F:hdim7", "76": "F:7", "77": "F:min6", "78": "F:maj7", "79": "F#", "80": "F#:dim", "81": "F#:sus4", "82": "F#:min7", "83": "F#:min", "84": "F#:sus2", "85": "F#:aug", "86": "F#:dim7", "87": "F#:maj6", "88": "F#:hdim7", "89": "F#:7", "90": "F#:min6", "91": "F#:maj7", "92": "G", "93": "G:dim", "94": "G:sus4", "95": "G:min7", "96": "G:min", "97": "G:sus2", "98": "G:aug", "99": "G:dim7", "100": "G:maj6", "101": "G:hdim7", "102": "G:7", "103": "G:min6", "104": "G:maj7", "105": "G#", "106": "G#:dim", "107": "G#:sus4", "108": "G#:min7", "109": "G#:min", "110": "G#:sus2", "111": "G#:aug", "112": "G#:dim7", "113": "G#:maj6", "114": "G#:hdim7", "115": "G#:7", "116": "G#:min6", "117": "G#:maj7", "118": "A", "119": "A:dim", "120": "A:sus4", "121": "A:min7", "122": "A:min", "123": "A:sus2", "124": "A:aug", "125": "A:dim7", "126": "A:maj6", "127": "A:hdim7", "128": "A:7", "129": "A:min6", "130": "A:maj7", "131": "A#", "132": "A#:dim", "133": "A#:sus4", "134": "A#:min7", "135": "A#:min", "136": "A#:sus2", "137": "A#:aug", "138": "A#:dim7", "139": "A#:maj6", "140": "A#:hdim7", "141": "A#:7", "142": "A#:min6", "143": "A#:maj7", "144": "B", "145": "B:dim", "146": "B:sus4", "147": "B:min7", "148": "B:min", "149": "B:sus2", "150": "B:aug", "151": "B:dim7", "152": "B:maj6", "153": "B:hdim7", "154": "B:7", "155": "B:min6", "156": "B:maj7"}
dataset/vevo_meta/chord_root.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"N": 0, "C": 1, "C#": 2, "D": 3, "D#": 4, "E": 5, "F": 6, "F#": 7, "G": 8, "G#": 9, "A": 10, "A#": 11, "B": 12}
dataset/vevo_meta/chord_root_inv.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "0": "N",
3
+ "1": "C",
4
+ "2": "C#",
5
+ "3": "D",
6
+ "4": "D#",
7
+ "5": "E",
8
+ "6": "F",
9
+ "7": "F#",
10
+ "8": "G",
11
+ "9": "G#",
12
+ "10": "A",
13
+ "11": "A#",
14
+ "12": "B"
15
+ }
dataset/vevo_meta/exclude.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 453
dataset/vevo_meta/idlist.txt ADDED
@@ -0,0 +1,748 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 001-Luis Fonsi - Despacito ft. Daddy Yankee kJQP7kiw5Fk
2
+ 002-Mark Ronson - Uptown Funk (Official Video) ft. Bruno Mars OPf0YbXqDm0
3
+ 003-Maroon 5 - Sugar (Official Music Video) 09R8_2nJtjg
4
+ 004-Justin Bieber - Sorry (PURPOSE - The Movement) fRh_vgS2dFE
5
+ 005-Katy Perry - Roar (Official) CevxZvSJLk8
6
+ 006-OneRepublic - Counting Stars (Official Music Video) hT_nvWreIhg
7
+ 007-Katy Perry - Dark Horse (Official) ft. Juicy J 0KSOMA3QBU0
8
+ 008-Crazy Frog - Axel F (Official Video) k85mRPqvMbE
9
+ 009-Enrique Iglesias - Bailando ft. Descemer Bueno, Gente De Zona (Español) NUsoVlDFqZg
10
+ 010-Taylor Swift - Shake It Off nfWlot6h_JM
11
+ 011-J Balvin, Willy William - Mi Gente (Official Video) wnJ6LuUFpMo
12
+ 012-Shakira - Waka Waka (This Time for Africa) (The Official 2010 FIFA World Cup™ Song) pRpeEdMmmQ0
13
+ 013-Adele - Hello YQHsXMglC9A
14
+ 014-Taylor Swift - Blank Space e-ORhEE9VVg
15
+ 016-Shakira - Chantaje (Official Video) ft. Maluma 6Mgqbai3fKo
16
+ 017-Justin Bieber - Baby (Official Music Video) ft. Ludacris kffacxfA7G4
17
+ 018-Calvin Harris - This Is What You Came For (Official Video) ft. Rihanna kOkQ4T5WO9E
18
+ 019-Fifth Harmony - Work from Home (Official Video) ft. Ty Dolla $ign 5GL9JoH4Sws
19
+ 020-Meghan Trainor - All About That Bass 7PCkvCPvDXk
20
+ 021-Sia - Chandelier (Official Video) 2vjPBrBU-TM
21
+ 022-Eminem - Love The Way You Lie ft. Rihanna uelHwf8o7_U
22
+ 023-Ellie Goulding - Love Me Like You Do (Official Video) AJtDXIazrMo
23
+ 024-Shawn Mendes - Treat You Better lY2yjAdbvdQ
24
+ 025-Justin Bieber - What Do You Mean (Official Music Video) DK_0jXPuIr0
25
+ 026-MAGIC! - Rude (Official Video) PIh2xe4jnpk
26
+ 027-Luis Fonsi, Demi Lovato - Échame La Culpa (Video Oficial) TyHvyGVs42U
27
+ 028-Avicii - Wake Me Up (Official Video) IcrbM1l_BoI
28
+ 029-LMFAO ft. Lauren Bennett, GoonRock - Party Rock Anthem (Official Video) KQ6zr6kCPj8
29
+ 030-Imagine Dragons - Believer 7wtfhZwyrcc
30
+ 031-Becky G, Bad Bunny - Mayores (Official Video) GMFewiplIbw
31
+ 032-John Legend - All of Me (Official Video) 450p7goxZqg
32
+ 033-Fifth Harmony - Worth It (Official Video) ft. Kid Ink YBHQbu5rbdQ
33
+ 035-The Weeknd - Starboy ft. Daft Punk (Official Video) 34Na4j8AVgA
34
+ 036-Ariana Grande ft. Nicki Minaj - Side To Side (Official Video) ft. Nicki Minaj SXiSVQZLje8
35
+ 037-Adele - Rolling in the Deep (Official Music Video) rYEDA3JcQqw
36
+ 038-Rihanna - Diamonds lWA2pjMjpBs
37
+ 039-Jennifer Lopez - On The Floor ft. Pitbull t4H_Zoh7G5A
38
+ 041-Silentó - Watch Me (Whip_Nae Nae) (Official) vjW8wmF5VWc
39
+ 042-Romeo Santos - Propuesta Indecente (Official Video) QFs3PIZb3js
40
+ 043-J. Balvin - Ay Vamos (Official Video) TapXs54Ah3E
41
+ 044-Adele - Someone Like You (Official Music Video) hLQl3WQQoQ0
42
+ 045-Drake - Hotline Bling uxpDa-c-4Mc
43
+ 046-Guns N' Roses - November Rain 8SbUC-UaAxE
44
+ 047-ZAYN - Dusk Till Dawn (Official Video) ft. Sia tt2k8PGm-TI
45
+ 048-The Chainsmokers - Don't Let Me Down (Official Video) ft. Daya Io0fBr1XBUA
46
+ 049-The Weeknd - The Hills (Official Video) yzTuBuRdAyA
47
+ 050-Imagine Dragons - Thunder fKopy74weus
48
+ 051-Jessie J, Ariana Grande, Nicki Minaj - Bang Bang (Official Video) 0HDdjwpPM3Y
49
+ 052-Ricky Martin - Vente Pa' Ca (Official Video) ft. Maluma iOe6dI2JhgU
50
+ 054-CNCO - Reggaetón Lento (Bailemos) 7jpqqBX-Myw
51
+ 055-Chino y Nacho - Andas En Mi Cabeza ft. Daddy Yankee (Video Oficial) AMTAQ-AJS4Y
52
+ 056-Justin Bieber - Love Yourself (Official Music Video) oyEuk8j8imI
53
+ 057-DJ Khaled - I'm The One ft. Justin Bieber, Quavo, Chance the Rapper, Lil Wayne weeI1G46q0o
54
+ 058-Eminem - Not Afraid (Official Video) j5-yKhDd64s
55
+ 059-Calvin Harris - Summer (Official Video) ebXbLfLACGM
56
+ 060-CAN'T STOP THE FEELING! (from DreamWorks Animation's 'TROLLS') (Official Video) ru0K8uYEZWw
57
+ 061-Lady Gaga - Bad Romance (Official Music Video) qrO4YZeyl0I
58
+ 062-Carlos Vives, Sebastián Yatra - Robarte un Beso (Official Video) Mtau4v6foHA
59
+ 063-Ellie Goulding - Burn (Official Video) CGyEd0aKWZE
60
+ 064-Calvin Harris & Disciples - How Deep Is Your Love EgqUJOudrcM
61
+ 065-Carlos Vives, Shakira - La Bicicleta -UV0QGLmYys
62
+ 066-Taylor Swift - Bad Blood ft. Kendrick Lamar QcIy9NiNbmo
63
+ 067-Mike Posner - I Took A Pill In Ibiza (Seeb Remix) (Explicit) foE1mO2yM04
64
+ 068-Sam Smith - I'm Not The Only One (Official Video) nCkpzqqog4k
65
+ 069-Rag'n'Bone Man - Human (Official Video) L3wKzyIN1yk
66
+ 070-Carly Rae Jepsen - Call Me Maybe fWNaR-rxAic
67
+ 071-Shawn Mendes - Stitches (Official Video) VbfpW0pbvaU
68
+ 072-Wisin - Escápate Conmigo (Official Video) ft. Ozuna 3X9wEwulYhk
69
+ 073-Post Malone - Congratulations ft. Quavo SC4xMk98Pdc
70
+ 074-Nirvana - Smells Like Teen Spirit (Official Music Video) hTWKbfoikeg
71
+ 075-Gente de Zona - La Gozadera (Official Video) ft. Marc Anthony VMp55KH_3wo
72
+ 076-Katy Perry - Last Friday Night (T.G.I.F.) (Official Music Video) KlyXNRrsk4A
73
+ 077-P!nk - Just Give Me A Reason ft. Nate Ruess OpQFFLBMEPI
74
+ 078-Katy Perry - Firework (Official Music Video) QGJuMBdaqIw
75
+ 079-Imagine Dragons - Radioactive ktvTqknDobU
76
+ 080-Pitbull - Timber (Official Video) ft. Ke$ha hHUbLv4ThOo
77
+ 081-French Montana - Unforgettable ft. Swae Lee CTFtOOh47oo
78
+ 082-50 Cent - In Da Club (Official Music Video) 5qm8PH4xAss
79
+ 083-Guns N' Roses - Sweet Child O' Mine (Official Music Video) 1w7OgIMMRc4
80
+ 084-One Direction - What Makes You Beautiful (Official Video) QJO3ROT-A4E
81
+ 085-Ariana Grande ft. Iggy Azalea - Problem (Official Video) iS1g8G_njx8
82
+ 086-Sam Smith - Too Good At Goodbyes (Official Video) J_ub7Etch2U
83
+ 087-AronChupa - I'm an Albatraoz _ OFFICIAL VIDEO Bznxx12Ptl0
84
+ 088-Taylor Swift - Look What You Made Me Do 3tmd-ClpJxA
85
+ 089-Chris Jedi - Ahora Dice (Official Video) ft. J. Balvin, Ozuna, Arcángel c73Cu3TQnlg
86
+ 090-Joey Montana - Picky RqpKDkVzlqU
87
+ 091-Eminem - Without Me (Official Music Video) YVkUvmDQ3HY
88
+ 092-Prince Royce - Darte un Beso bdOXnTbyk0g
89
+ 093-Taylor Swift - You Belong With Me VuNIsY6JdUw
90
+ 094-Eminem - Rap God (Explicit) XbGs_qK2PQA
91
+ 095-Don Omar - Danza Kuduro ft. Lucenzo 7zp1TbLFPp8
92
+ 096-Maluma - El Perdedor (Official Video) PJniSb91tvo
93
+ 097-Rihanna - Work (Explicit) ft. Drake HL1UzIK-flA
94
+ 098-Ricky Martin - La Mordidita (Official Video) ft. Yotuel lBztnahrOFw
95
+ 099-Beyoncé - Halo bnVUHWCynig
96
+ 100-The Weeknd - Can't Feel My Face (Official Video) KEI4qSrkPAs
97
+ 101-Shakira - La La La (Brazil 2014) ft. Carlinhos Brown 7-7knsP2n5w
98
+ 102-Sia - Elastic Heart feat. Shia LaBeouf & Maddie Ziegler (Official Video) KWZGAExj-es
99
+ 103-Katy Perry - Bon Appétit (Official) ft. Migos dPI-mRFEIH0
100
+ 104-The Cranberries - Zombie (Official Music Video) 6Ejga4kJUts
101
+ 105-Shakira - Can't Remember to Forget You (Official Video) ft. Rihanna o3mP3mJDL2k
102
+ 106-Daddy Yankee - Limbo (Video Oficial) 6BTjG-dhf5s
103
+ 107-Whitney Houston - I Will Always Love You (Official 4K Video) 3JWTaaS7LdU
104
+ 108-Miley Cyrus - Wrecking Ball (Official Video) My2FRPA3Gf8
105
+ 109-Chris Brown - Loyal (Official Video) ft. Lil Wayne, Tyga JXRN_LkCa_o
106
+ 110-Pitbull - Rain Over Me ft. Marc Anthony SmM0653YvXU
107
+ 111-Enrique Iglesias - El Perdedor (Pop) ft. Marco Antonio Solís tLcfAnN2QgY
108
+ 112-J Balvin - 6 AM ft. Farruko (Official Video) yUV9JwiQLog
109
+ 113-System Of A Down - Chop Suey! (Official HD Video) CSvFpBOe8eY
110
+ 114-Naughty Boy - La la la ft. Sam Smith (Official Video) 3O1_3zBUKM8
111
+ 115-Rick Astley - Never Gonna Give You Up (Official Music Video) dQw4w9WgXcQ
112
+ 116-Ariana Grande - Break Free ft. Zedd L8eRzOYhLuw
113
+ 117-Sam Smith - Stay With Me (Official Video) pB-5XG-DbAA
114
+ 118-Michael Jackson - Billie Jean (Official Video) Zi_XLOBDo_Y
115
+ 119-Nelly - Dilemma (Official Music Video) ft. Kelly Rowland 8WYHDfJDPDc
116
+ 120-ZAYN - PILLOWTALK (Official Music Video) C_3d6GntKbk
117
+ 121-DJ Snake, Lil Jon - Turn Down for What HMUDVMiITOU
118
+ 122-Katy Perry - Hot N Cold (Official) kTHNpusq654
119
+ 123-Iggy Azalea - Fancy ft. Charli XCX (Official Music Video) O-zpOMYRi0w
120
+ 124-Bon Jovi - It's My Life (Official Music Video) vx2u5uUu3DE
121
+ 125-Chino & Nacho - Me Voy Enamorando ft. Farruko (Remix) (Official Music Video) 0yr75-gxVtM
122
+ 126-Marc Anthony - Vivir Mi Vida (Official Video) YXnjy5YlDwk
123
+ 127-Justin Bieber - Never Say Never (Official Music Video) ft. Jaden Smith _Z5-P9v3F8w
124
+ 128-Shawn Mendes - There's Nothing Holdin' Me Back dT2owtxkU8k
125
+ 129-Enrique Iglesias - DUELE EL CORAZON ft. Wisin xFutjZEBTXs
126
+ 130-DJ Khaled - Wild Thoughts (Official Video) ft. Rihanna, Bryson Tiller fyaI4-5849w
127
+ 131-Maluma - Sin Contrato (Official Video) 9xByMBYDRmY
128
+ 132-Nicki Minaj - Anaconda LDZX4ooRsWs
129
+ 133-Maluma - Borro Cassette (Official Video) Xk0wdDTTPA0
130
+ 134-AC_DC - Thunderstruck (Official Video) v2AC41dglnM
131
+ 135-Romeo Santos - Eres Mía 8iPcqtHoR3U
132
+ 136-Backstreet Boys - I Want It That Way (Official HD Video) 4fndeDfaWCg
133
+ 137-Shakira - Hips Don't Lie (Official 4K Video) ft. Wyclef Jean DUT5rEU6pqM
134
+ 138-Camila Cabello - Havana ft. Young Thug BQ0mxQXmLsk
135
+ 139-Rihanna - We Found Love ft. Calvin Harris tg00YEETFzg
136
+ 140-J Balvin - Safari ft. Pharrell Williams, BIA, Sky (Official Video) JWESLtAKKlU
137
+ 141-Rihanna - Stay ft. Mikky Ekko JF8BRvqGCNs
138
+ 142-Maluma - Cuatro Babys (Official Video) ft. Trap Capos, Noriel, Bryant Myers, Juhn OXq-JP8w5H4
139
+ 143-Cyndi Lauper - Girls Just Want To Have Fun (Official Video) PIb6AZdTr-A
140
+ 144-Evanescence - Bring Me To Life (Official Music Video) 3YxaaGgTQYM
141
+ 145-Justin Bieber - Beauty And A Beat ft. Nicki Minaj (Official Music Video) Ys7-6_t7OEQ
142
+ 146-One Direction - Drag Me Down (Official Video) Jwgf3wmiA04
143
+ 147-Auli'i Cravalho - How Far I'll Go (from Moana_Official Video) cPAbx5kgCJo
144
+ 148-Aqua - Barbie Girl (Official Music Video) ZyhrYis509A
145
+ 149-Dr. Dre ft. Snoop Dogg - Still D.R.E. (Official Video) _CL6n0FJZpk
146
+ 150-Justin Timberlake - Mirrors (Official Video) uuZE_IRwLNI
147
+ 151-Katy Perry - Wide Awake (Official Video) k0BWlvnBmIE
148
+ 152-J Balvin - Si Tu Novio Te Deja Sola ft. Bad Bunny (Official Video) Km4BayZykwE
149
+ 153-Maroon 5 - One More Night (Official Music Video) fwK7ggA3-bU
150
+ 154-Imagine Dragons - Demons (Official Video) mWRsgZuwf_8
151
+ 155-Ariana Grande - Focus lf_wVfwpfp8
152
+ 156-Europe - The Final Countdown (Official Video) 9jK-NcRmVcw
153
+ 157-Lady Gaga - Poker Face (Official Music Video) bESGLojNYSo
154
+ 158-Post Malone - rockstar ft. 21 Savage UceaB4D0jpo
155
+ 159-Ayo & Teo - Rolex (Official Video) lwk5OUII9Vc
156
+ 160-Thalia - Desde Esa Noche (Premio Lo Nuestro 2016) ft. Maluma 6C_s56iscpQ
157
+ 161-Cali Y El Dandee - Por Fin Te Encontré ft. Juan Magan, Sebastian Yatra (Video Oficiel) _kxz7WX4mLU
158
+ 162-One Direction - Story of My Life W-TE_Ys4iwM
159
+ 163-Miley Cyrus - We Can't Stop (Official Video) LrUvu1mlWco
160
+ 164-Mike WiLL Made-It - 23 ft. Miley Cyrus, Wiz Khalifa, Juicy J (Official Music Video) bbEoRnaOIbs
161
+ 165-Scorpions - Wind Of Change (Official Music Video) n4RjJKxsamQ
162
+ 166-Nicki Minaj - Super Bass 4JipHEz53sU
163
+ 167-Karol G, Bad Bunny - Ahora Me Llama (Official Video) 4NNRy_Wz16k
164
+ 168-Tove Lo - Habits (Stay High) - Hippie Sabotage Remix SYM-RJwSGQ8
165
+ 169-Harry Styles - Sign of the Times (Official Video) qN4ooNx77u0
166
+ 170-The Police - Every Breath You Take (Official Video) OMOGaugKpzs
167
+ 171-Avicii - Waiting For Love cHHLHGNpCSA
168
+ 172-Ariana Grande - Into You (Official Video) 1ekZEVeXwek
169
+ 173-will.i.am - Scream & Shout ft. Britney Spears (Official Music Video) kYtGl1dX5qI
170
+ 174-Rihanna - What's My Name (Official Music Video) ft. Drake U0CGsw6h60k
171
+ 175-Katy Perry - Part Of Me (Official) uuwfgXD8qV8
172
+ 176-Pitbull - Give Me Everything ft. Ne-Yo, Afrojack, Nayer EPo5wWmKEaI
173
+ 177-Audioslave - Like a Stone (Official Video) 7QU1nvuxaMA
174
+ 178-HA-ASH - Perdón, Perdón (Primera Fila - Hecho Realidad [En Vivo]) _wL3Pc-EmjA
175
+ 179-Katy Perry - The One That Got Away (Official Music Video) Ahha3Cqe_fk
176
+ 180-Nacho, Yandel, Bad Bunny - Báilame (Remix) T7VewKI44rQ
177
+ 181-Sean Kingston - Beautiful Girls MrTz5xjmso4
178
+ 182-LMFAO - Sexy and I Know It (Official Video) wyx6JDQCslE
179
+ 183-Eminem - When I'm Gone (Official Music Video) 1wYNFfgrXTI
180
+ 184-Michael Jackson - They Don’t Care About Us (Brazil Version) (Official Video) QNJL6nfu__Q
181
+ 185-Lorde - Royals (US Version) nlcIKh6sBtc
182
+ 186-R. City - Locked Away ft. Adam Levine 6GUm5g8SG4o
183
+ 187-John Newman - Love Me Again CfihYWRWRTQ
184
+ 188-No Doubt - Don't Speak (Official 4K Music Video) TR3Vdo5etCQ
185
+ 189-Bon Jovi - Livin' On A Prayer (Official Music Video) lDK9QqIzhwk
186
+ 190-Stromae - Papaoutai oiKj0Z_Xnjc
187
+ 191-Rae Sremmurd - Black Beatles ft. Gucci Mane (Official Video) b8m9zhNAgKs
188
+ 192-Little Mix - Black Magic (Official Video) MkElfR_NPBI
189
+ 193-Shakira - Perro Fiel (Official Video) ft. Nicky Jam SHq2qrFUlGY
190
+ 194-Wisin - Adrenalina (Official Video) ft. Jennifer Lopez, Ricky Martin ME2Hufquz0k
191
+ 195-Beyoncé - Single Ladies (Put a Ring on It) (Video Version) 4m1EFMoRFvY
192
+ 196-Bonnie Tyler - Total Eclipse of the Heart (Video) lcOxhH8N3Bo
193
+ 197-Rihanna - Only Girl (In The World) (Official Music Video) pa14VNsdSYM
194
+ 198-Miley Cyrus - Party In The U.S.A. (Official Video) M11SvDtPBhA
195
+ 199-Rae Sremmurd - No Type (Official Video) wzMrK-aGCug
196
+ 200-J. Balvin - Ginza (Official Video) zZjSX01P5dE
197
+ 201-Justin Bieber - Boyfriend (Official Music Video) 4GuqB1BQVr4
198
+ 202-Akon - Smack That (Official Music Video) ft. Eminem bKDdT_nyP54
199
+ 203-Rihanna - Man Down sEhy-RXkNo0
200
+ 204-Indila - Dernière Danse (Clip Officiel) K5KAc5CoCuk
201
+ 205-Hoobastank - The Reason (Official Music Video) fV4DiAyExN0
202
+ 206-Kendrick Lamar - HUMBLE. tvTRZJ-4EyI
203
+ 207-Foster The People - Pumped Up Kicks (Official Video) SDTZ7iX4vTQ
204
+ 208-Khalid - Young Dumb & Broke (Official Video) IPfJnp1guPc
205
+ 209-Michael Jackson - Thriller (Official Video) sOnqjkJTMaA
206
+ 210-Pitbull - International Love (Official Video) ft. Chris Brown CdXesX6mYUE
207
+ 211-Calvin Harris - I Need Your Love (Official Video) ft. Ellie Goulding AtKZKl7Bgu0
208
+ 212-Eminem ft. Rihanna - The Monster (Explicit) [Official Video] EHkozMIXZ8w
209
+ 213-Evanescence - My Immortal (Official Music Video) 5anLPw0Efmo
210
+ 214-Swedish House Mafia ft. John Martin - Don't You Worry Child (Official Video) 1y6smkh6c-0
211
+ 215-George Michael - Careless Whisper (Official Video) izGwDsrQ1eQ
212
+ 216-Jennifer Lopez - Ain't Your Mama (Official Video) Pgmx7z49OEk
213
+ 217-Shakira - Me Enamoré (Official Video) sPTn0QEhxds
214
+ 218-We Are One (Ole Ola) [The Official 2014 FIFA World Cup Song] (Olodum Mix) TGtWWb9emYI
215
+ 219-AC_DC - Back In Black (Official Video) pAgnJDJN4VA
216
+ 220-Avicii - The Nights UtF6Jej8yb4
217
+ 221-La Adictiva Banda San José de Mesillas - Después de Ti, ¿Quién (Video Oficial) YWu9mB6X9Oc
218
+ 222-Kygo - Firestone ft. Conrad Sewell (Official Video) 9Sc-ir2UwGU
219
+ 223-Taylor Swift - Wildest Dreams IdneKLhsWOQ
220
+ 224-Bon Jovi - Always (Official Music Video) 9BMwcO6_hyA
221
+ 225-Maroon 5 - Animals (Official Music Video) qpgTC9MDx1o
222
+ 226-Farruko - Chillax ft. Ky-Mani Marley (Official Video) 7fEQmJ98x_Y
223
+ 227-Michael Jackson - Beat It (Official Video) oRdxUFDoQe0
224
+ 228-Bobby Shmurda - Hot N_gga (Official Music Video) vJwKKKd2ZYE
225
+ 229-Adele - Send My Love (To Your New Lover) fk4BbF7B29w
226
+ 230-Robin Thicke - Blurred Lines ft. T.I., Pharrell (Official Music Video) yyDUC1LUXSU
227
+ 231-Calvin Harris - Blame ft. John Newman 6ACl8s_tBzE
228
+ 232-Jessie J - Price Tag ft. B.o.B qMxX-QOV9tI
229
+ 233-Katy Perry - This Is How We Do (Official) 7RMQksXpQSk
230
+ 234-Don Omar - Taboo lRWqYR3e7xE
231
+ 235-Romeo Santos - Yo También (Official Video) ft. Marc Anthony QBaIMZ8QjcU
232
+ 236-Alvaro Soler - Sofia (Official Music Video) qaZ0oAh4evU
233
+ 237-Rihanna - Umbrella (Orange Version) (Official Music Video) ft. JAY-Z CvBfHwUxHIk
234
+ 238-Farruko, Bad Bunny, Rvssian - Krippy Kush (Official Video) j1_JW7An2l0
235
+ 239-Selena Gomez - The Heart Wants What It Wants (Official Video) ij_0p_6qTss
236
+ 240-Enrique Iglesias, Juan Luis Guerra - Cuando Me Enamoro (Official Music Video) 4DO8GsIYfhQ
237
+ 241-Zara Larsson - Lush Life tD4HCZe-tew
238
+ 242-The Verve - Bitter Sweet Symphony (Official Music Video) 1lyu1KKwC74
239
+ 243-The Black Eyed Peas - Where Is The Love (Official Music Video) WpYeekQkAdc
240
+ 244-One Direction - Best Song Ever o_v9MY_FMcw
241
+ 245-Maroon 5 - Moves Like Jagger ft. Christina Aguilera (Official Music Video) iEPTlhBmwRg
242
+ 246-Sia - The Greatest GKSRyLdjsPA
243
+ 247-Akon - Lonely (Official Music Video) 6EEW-9NDM5k
244
+ 248-Ariana Grande, The Weeknd - Love Me Harder (Official Video) g5qU7p7yOY8
245
+ 249-50 Cent - Candy Shop (Official Music Video) ft. Olivia SRcnnId15BA
246
+ 250-Selena Gomez - Come & Get It n-D1EB74Ckg
247
+ 251-Meghan Trainor - Like I'm Gonna Lose You (Official Video) ft. John Legend 2-MBfn8XjIU
248
+ 252-Jonas Blue - Mama ft. William Singe (Official Video) qPTfXwPf_HM
249
+ 253-One Direction - One Thing Y1xs_xPb46M
250
+ 254-Mariah Carey - All I Want For Christmas Is You (Official Video) yXQViqx6GMY
251
+ 255-Jonas Blue - Perfect Strangers ft. JP Cooper (Official Video) Ey_hgKCCYU4
252
+ 256-Maroon 5 - Payphone ft. Wiz Khalifa (Explicit) (Official Music Video) KRaWnd3LJfs
253
+ 257-Simone & Simaria - Loka (Ao Vivo) ft. Anitta UrT0zCmsN8c
254
+ 258-Future - Low Life (Official Music Video) ft. The Weeknd K_9tX4eHztY
255
+ 259-Silvestre Dangond, Nicky Jam - Cásate Conmigo (Official Video) cpN78ZjnCZY
256
+ 261-One Direction - Live While We're Young AbPED9bisSc
257
+ 262-Lil Wayne - Mirror ft. Bruno Mars (Official Music Video) OZLUa8JUR18
258
+ 263-Katy Perry - Chained To The Rhythm (Official) ft. Skip Marley Um7pMggPnug
259
+ 264-Justin Bieber - One Time (Official Music Video) CHVhwcOg6y8
260
+ 265-Dillon Francis, DJ Snake - Get Low (Official Music Video) 12CeaxLiMgE
261
+ 266-The Weeknd - Earned It (from Fifty Shades Of Grey) (Official Video - Explicit) waU75jdUnYw
262
+ 267-Taylor Swift - Style -CmadmM5cOk
263
+ 268-Adele - Set Fire To The Rain (Live at The Royal Albert Hall) Ri7-vnrJD3k
264
+ 269-Wham! - Last Christmas (Official Video) E8gmARGvPlI
265
+ 270-3 Doors Down - Here Without You (Official Music Video) kPBzTxZQG5Q
266
+ 271-Shakira - Try Everything (Official Video) c6rP-YP4c5I
267
+ 272-Guns N' Roses - Paradise City Rbm6GXllBiw
268
+ 273-MC Hammer - U Can't Touch This (Official Music Video) otCpCn0l4Wo
269
+ 274-Taylor Swift - We Are Never Ever Getting Back Together WA4iX5D9Z64
270
+ 275-The Black Eyed Peas - Pump It (Official Music Video) ZaI2IlHwmgQ
271
+ 276-Sia - Cheap Thrills (Performance Edit) 31crA53Dgu0
272
+ 277-Nelly Furtado - Say It Right (Official Music Video) 6JnGBs88sL0
273
+ 278-Britney Spears - ...Baby One More Time (Official Video) C-u5WLJ9Yk4
274
+ 279-Banda Los Recoditos - Mi Último Deseo (Video Oficial) cVlAmP-KDT4
275
+ 280-Jessie J - Flashlight (from Pitch Perfect 2) (Official Video) DzwkcbTQ7ZE
276
+ 282-Demi Lovato - Heart Attack (Official Video) AByfaYcOm4A
277
+ 283-Meghan Trainor - Me Too qDRORgoZxZU
278
+ 284-Guns N' Roses - Don't Cry zRIbf6JqkNc
279
+ 285-Bastille - Pompeii (Official Music Video) F90Cw4l-8NY
280
+ 286-Akon - Right Now (Na Na Na) (Official Video) vIaH35-MLsk
281
+ 287-Katy Perry - Swish Swish (Official) ft. Nicki Minaj iGk5fR-t5AU
282
+ 288-Shakira - La Tortura (Official HD Video) ft. Alejandro Sanz Dsp_8Lm1eSk
283
+ 289-ZAYN, Taylor Swift - I Don’t Wanna Live Forever (Fifty Shades Darker) 7F37r50VUTQ
284
+ 290-Ariana Grande - Dangerous Woman 9WbCfHutDSE
285
+ 291-Pitbull - Feel This Moment (Official Video) ft. Christina Aguilera 5jlI4uzZGjU
286
+ 292-Selena Gomez & The Scene - Love You Like A Love Song EgT_us6AsDg
287
+ 293-Wisin, Carlos Vives - Nota de Amor (Official Video) ft. Daddy Yankee wZRWpr1G1Qw
288
+ 294-Beyoncé - Drunk in Love (Explicit) ft. JAY Z p1JPKLa-Ofc
289
+ 295-Romeo Santos - La Diabla_Mi Santa ft. Tomatito Hz9lhqxl_gQ
290
+ 296-Maroon 5 - She Will Be Loved (Official Music Video) nIjVuRTm-dc
291
+ 297-The Black Eyed Peas - My Humps iEe_eraFWWs
292
+ 298-Duke Dumont - Ocean Drive (Official Music Video) KDxJlW6cxRk
293
+ 299-Iggy Azalea - Black Widow ft. Rita Ora (Official Music Video) u3u22OYqFGo
294
+ 300-Justin Bieber - Company (Official Music Video) gdx7gN1UyX0
295
+ 301-Anna Kendrick - Cups (Pitch Perfect’s “When I’m Gone”) [Official Video] cmSbXsFE3l8
296
+ 302-J Balvin - Bobo (Official Video) 0GvLP2C2w9U
297
+ 303-Alicia Keys - No One (Official Music Video) rywUS-ohqeE
298
+ 304-Adele - When We Were Young (Live at The Church Studios) DDWKuo3gXMQ
299
+ 305-Waka Waka (Esto es Africa) (Cancion Oficial de la Copa Mundial de la FIFA� Sudafrica 2010) dzsuE5ugxf4
300
+ 306-Katy Perry - California Gurls (Official Music Video) ft. Snoop Dogg F57P9C4SAW4
301
+ 307-The Pussycat Dolls - Buttons (Official Music Video) ft. Snoop Dogg VCLxJd1d84s
302
+ 308-Taylor Swift - Love Story 8xg3vE8Ie_E
303
+ 309-Demi Lovato - Let It Go (from 'Frozen') (Official Video) kHue-HaXXzg
304
+ 311-Calvin Harris - Outside (Official Video) ft. Ellie Goulding J9NQFACZYEU
305
+ 312-Shakira - Whenever, Wherever (Official HD Video) weRHyjj34ZE
306
+ 313-Maroon 5 - What Lovers Do ft. SZA (Official Music Video) 5Wiio4KoGe8
307
+ 314-Wisin & Yandel - Follow The Leader ft. Jennifer Lopez Xmap94TcDNs
308
+ 315-Enrique Iglesias - Loco ft. Romeo Santos RSyUWjftHrs
309
+ 316-Toni Braxton - Un-Break My Heart (Official HD Video) p2Rch6WvPJE
310
+ 317-Daddy Yankee - Sígueme y Te Sigo (Video Oficial) EfF9EE6ZR5E
311
+ 318-Ke$ha - TiK ToK (Official HD Video) iP6XpLQM2Cs
312
+ 319-Katy Perry - E.T. ft. Kanye West (Official Music Video) t5Sd5c4o9UM
313
+ 320-Meghan Trainor - NO cMTAUr3Nm6I
314
+ 321-Katy Perry - Unconditionally (Official) XjwZAa2EjKA
315
+ 322-Taylor Swift - 22 AgFeZr5ptV8
316
+ 323-Roxette - It Must Have Been Love (Official Music Video) k2C5TjS2sh4
317
+ 324-Capital Cities - Safe And Sound (Official Music Video) 47dtFZ8CFo8
318
+ 325-Shakira - Loca (Spanish Version) ft. El Cata XAhTt60W7qo
319
+ 326-Wisin & Yandel - Algo Me Gusta De Ti ft. Chris Brown, T-Pain 3rgwIp6D3ow
320
+ 327-Rihanna - Rude Boy (Official Music Video) e82VE8UtW8A
321
+ 328-Beyoncé - Crazy In Love ft. JAY Z ViwtNLUqkMY
322
+ 329-Rihanna - Don't Stop The Music yd8jh9QYfEs
323
+ 330-Meghan Trainor - Dear Future Husband (Official Video) ShlW5plD_40
324
+ 331-Eminem - Mockingbird (Official Music Video) S9bCLPwzSC0
325
+ 332-A Great Big World, Christina Aguilera - Say Something -2U0Ivkn2Ds
326
+ 333-Nelly - Just A Dream (Official Music Video) N6O2ncUKvlg
327
+ 334-Meghan Trainor - Lips Are Movin (Official Music Video) qDc_5zpBj7s
328
+ 335-Avril Lavigne - Girlfriend Bg59q4puhmg
329
+ 336-Rihanna - Take A Bow (Official Music Video) J3UjJ4wKLkg
330
+ 337-The Black Eyed Peas - I Gotta Feeling (Official Music Video) uSD4vsh1zDA
331
+ 338-Rihanna - Where Have You Been HBxt_v0WF6Y
332
+ 339-Avicii - Levels _ovdm2yX4MA
333
+ 340-Eminem - No Love (Explicit Version) ft. Lil Wayne KV2ssT8lzj8
334
+ 341-Rachel Platten - Fight Song (Official Video) xo1VInw-SKc
335
+ 342-LMFAO - Sorry For Party Rocking SkTt9k4Y-a8
336
+ 343-Abba - Dancing Queen (Official Music Video Remastered) xFrGuyw1V8s
337
+ 344-The Black Eyed Peas - The Time (Dirty Bit) (Official Music Video) JwQZQygg3Lk
338
+ 345-Plan B - Mi Vecinita SB8-YY2DyHI
339
+ 346-One Direction - You & I _kqQDCxRCzM
340
+ 347-Jennifer Lopez - Dance Again (Official Video) ft. Pitbull bjgFH01k0gU
341
+ 348-Britney Spears - Toxic (Official HD Video) LOZuxwVk7TU
342
+ 349-Chris Brown - With You (Official Video) nmjdaBaZe8Y
343
+ 351-G-Eazy x Bebe Rexha - Me, Myself & I bSfpSOBD30U
344
+ 352-Chris Brown - Look at Me Now (Official Video) ft. Lil Wayne, Busta Rhymes 8gyLR4NfMiI
345
+ 353-Beyoncé - If I Were A Boy AWpsOqh8q0M
346
+ 354-Beyoncé - Run the World (Girls) (Official Video) VBmMU_iwe6U
347
+ 355-Rich Gang ft. Young Thug, Rich Homie Quan - Lifestyle (Official Video) nGt_JGHYEO4
348
+ 356-One Direction - Kiss You (Official) T4cdfRohhcg
349
+ 357-Pia Mia - Do It Again ft. Chris Brown, Tyga (Official Music Video) cNw8A5pwbVI
350
+ 358-HA-ASH - Te Dejo En Libertad (En Vivo) ZxvI1epOAWE
351
+ 359-Maître Gims - Bella (Clip officiel) rMltoD1jCGI
352
+ 360-Selena Gomez - Kill Em With Kindness HHP5MKgK0o8
353
+ 361-AC_DC - Highway to Hell (Live At River Plate, December 2009) gEPmA3USJdI
354
+ 362-Imagine Dragons - It's Time sENM2wA_FTg
355
+ 363-Lana Del Rey - Born To Die (Official Music Video) Bag1gUxuU0g
356
+ 364-Sean Kingston, Justin Bieber - Eenie Meenie (Video Version) prmmCg5bKxA
357
+ 365-Alejandro Fernández - Hoy Tengo Ganas De Ti ft. Christina Aguilera (Video Oficial) Z81hsLIY1sQ
358
+ 366-Prince Royce, Shakira - Deja vu (Official Video) XEvKn-QgAY0
359
+ 367-Camila - Mientes (Video) xftFxCYQTdk
360
+ 368-Dr. Dre ft. Snoop Dogg, Kurupt, Nate Dogg - The Next Episode (Official Video) QZXc39hT8t4
361
+ 369-Soulja Boy Tell'em - Crank That (Soulja Boy) (Official Music Video) 8UFIYGkROII
362
+ 370-The Script - Hall of Fame (Official Video) ft. will.i.am mk48xRzuNvA
363
+ 371-Zara Larsson, MNEK - Never Forget You GTyN-DB_v5M
364
+ 372-Mariah Carey - We Belong Together (Official Music Video) 0habxsuXW4g
365
+ 374-Mr. Probz - Waves (Robin Schulz Remix Radio Edit) pUjE9H8QlA4
366
+ 375-P!nk - Try (Official Video) yTCDVfMz15M
367
+ 376-Justin Bieber - I'll Show You (Official Music Video) PfGaX8G0f2E
368
+ 377-One Direction - Perfect (Official Video) Ho32Oh6b4jc
369
+ 378-Selena Gomez - Good For You 1TsVjvEkc4s
370
+ 379-Demi Lovato - Sorry Not Sorry (Official Video) -MsvER1dpjM
371
+ 380-Plan B - Fanatica Sensual Official Video QvypZSdjO8M
372
+ 381-Eminem - Stan (Long Version) ft. Dido gOMhN-hfMtY
373
+ 382-Nicki Minaj - Only ft. Drake, Lil Wayne, Chris Brown zXtsGAkyeIo
374
+ 383-Foo Fighters - The Pretender SBjQ9tuuTJQ
375
+ 384-Taylor Swift - I Knew You Were Trouble vNoKguSdy4Y
376
+ 385-Drake - Started From The Bottom (Explicit) RubBzkZzpUA
377
+ 386-Rihanna, Kanye West, Paul McCartney - FourFiveSeconds kt0g4dWxEBo
378
+ 387-Miley Cyrus - Malibu (Official Video) 8j9zMok6two
379
+ 388-Lady Antebellum - Need You Now eM213aMKTHg
380
+ 389-Beyoncé - Love On Top (Official Video) Ob7vObnFUJc
381
+ 390-Guns N' Roses - Welcome To The Jungle o1tj2zJ2Wvg
382
+ 391-Tyga - Hookah (Official Music Video) ft. Young Thug b-J95fYuVz4
383
+ 392-Justin Bieber - As Long As You Love Me ft. Big Sean (Official Music Video) R4em3LKQCAQ
384
+ 393-J Balvin - Tranquila (Official Video) HWyEEj2pSt0
385
+ 394-One Direction - Night Changes syFZfO_wfMQ
386
+ 395-Farruko - Passion Whine ft. Sean Paul (Official Video) MNmc_XJp5rI
387
+ 396-Lady Gaga - Alejandro niqrrmev4mA
388
+ 397-Justin Bieber - Somebody To Love Remix ft. Usher (Official Music Video) SOI4OF7iIr4
389
+ 398-J Balvin - Sigo Extrañándote (Official Video) nZ0zbsZOdwg
390
+ 399-Avril Lavigne - When You're Gone (Official Video) 0G3_kG5FFfQ
391
+ 400-Desiigner - Panda (Official Music Video) E5ONTXHS2mM
392
+ 402-The Calling - Wherever You Will Go (Official Video) iAP9AF6DCu4
393
+ 403-Nego do Borel - Você Partiu Meu Coração ft. Anitta, Wesley Safadão (Video Oficial) Xp-dKdSUuLk
394
+ 404-Louis Tomlinson - Back to You (Official Video) ft. Bebe Rexha, Digital Farm Animals -HjpL-Ns6_A
395
+ 405-Maroon 5 - Maps (Explicit) (Official Music Video) NmugSMBh_iI
396
+ 406-The Weeknd - Often (NSFW) (Official Video) JPIhUaONiLU
397
+ 407-Nicki Minaj - Right By My Side (Explicit) ft. Chris Brown he3DJLXbebI
398
+ 408-Cali Y El Dandee - Yo Te Esperaré _KSyWS8UgA4
399
+ 409-Lana Del Rey - Young and Beautiful (Official Music Video) o_1aF54DO60
400
+ 411-The Killers - Mr. Brightside (Official Music Video) gGdGFtwCNBE
401
+ 412-One Direction - One Way Or Another (Teenage Kicks) 36mCEZzzQ3o
402
+ 413-Lil Wayne - Lollipop ft. Static (Official Music Video) 2IH8tNQAzSs
403
+ 415-Sam Smith - Lay Me Down (Official Video) HaMq2nn5ac0
404
+ 416-Kungs vs Cookin’ on 3 Burners - This Girl (Official Music Video) 2Y6Nne8RvaA
405
+ 417-Becky G - Shower 50-_oTkmF5I
406
+ 418-Jennifer Lopez - Papi (Official Video) 6XbIuSLaCnk
407
+ 419-Selena Gomez - Same Old Love 9h30Bx4Klxg
408
+ 420-Justin Bieber - Mistletoe (Official Music Video) LUjn3RpkcKY
409
+ 421-Dr. Dre ft. Eminem, Skylar Grey - I Need A Doctor (Explicit) [Official Video] VA770wpLX-Q
410
+ 422-Akon - Don't Matter (Official Music Video) JWA5hJl4Dv0
411
+ 423-Kelly Clarkson - Because Of You (VIDEO) Ra-Om7UMSJc
412
+ 424-DNCE - Cake By The Ocean vWaRiD5ym74
413
+ 425-Fifth Harmony - All In My Head (Flex) (Official Video) ft. Fetty Wap jsbeemdD2rQ
414
+ 426-Timbaland - Apologize ft. OneRepublic ZSM3w1v-A_Y
415
+ 427-Beyoncé, Shakira - Beautiful Liar QrOe2h9RtWI
416
+ 428-Demi Lovato - Give Your Heart a Break (Official Video) 1zfzka5VwRc
417
+ 429-Ariana Grande - The Way ft. Mac Miller _sV0S8qWSy0
418
+ 430-Beyoncé - Irreplaceable 2EwViQxSJJQ
419
+ 431-Logic - 1-800-273-8255 ft. Alessia Cara, Khalid (Official Video) Kb24RrHIbFk
420
+ 432-50 Cent - 21 Questions (Official Music Video) ft. Nate Dogg cDMhlvbOFaM
421
+ 433-Enrique Iglesias - Hero (Official Music Video) koJlIGDImiU
422
+ 434-Miley Cyrus - The Climb NG2zyeVRcbs
423
+ 435-Owl City - Fireflies (Official Music Video) psuRGfAaju4
424
+ 436-Thalia - Equivocada (Live Version) QPeNUfc8hGk
425
+ 437-Avril Lavigne - Wish You Were Here (Video) VT1-sitWRtY
426
+ 439-Eminem - Beautiful (Official Music Video) lgT1AidzRWM
427
+ 440-Christina Aguilera, Lil' Kim, Mya, Pink - Lady Marmalade (Official Music Video) RQa7SvVCdZk
428
+ 441-Rihanna - Pour It Up (Explicit) ehcVomMexkY
429
+ 442-Rihanna - Unfaithful (Official Music Video) rp4UwPZfRis
430
+ 443-J. Balvin, Jowell & Randy - Bonita (Official Video) SqpvOqRieYY
431
+ 444-Selena Gomez - Hands To Myself FMlcn-_jpWY
432
+ 445-One Direction - History (Official Video) yjmp8CoZBIo
433
+ 446-Calvin Harris - My Way (Official Video) b4Bj7Zb-YD4
434
+ 447-Nicki Minaj - Starships (Explicit) SeIJmciN8mo
435
+ 448-Reik - Creo en Ti snFhcHHdzT0
436
+ 449-Kings Of Leon - Sex on Fire (Official Video) RF0HhrwIwp0
437
+ 450-Justin Bieber - Love Me (Official Music Video) qdDVtFvJwUc
438
+ 451-The Black Eyed Peas - Boom Boom Pow (Official Music Video) 4m48GqaOz90
439
+ 452-Justin Timberlake - Cry Me A River (Official Video) DksSPZTZES0
440
+ 453-Lady Gaga - Telephone ft. Beyoncé (Official Music Video) EVBsypHzF3U
441
+ 454-Eminem - Like Toy Soldiers (Official Video) lexLAjh8fPA
442
+ 455-Naughty Boy ft. Beyoncé, Arrow Benjamin - Runnin' (Lose It All) [Official Video] eJSik6ejkr0
443
+ 456-Lil Wayne - Love Me ft. Drake, Future (Explicit) (Official Music Video) KY44zvhWhp4
444
+ 457-Kelly Clarkson - Stronger (What Doesn't Kill You) [Official Video] Xn676-fLq7I
445
+ 458-Descendants Cast - Rotten to the Core (from Descendants) (Official Video) zGlLe1w3DJM
446
+ 459-P!nk - So What (Official Video) FJfFZqTlWrQ
447
+ 460-Timbaland - The Way I Are (Official Music Video) ft. Keri Hilson, D.O.E., Sebastian U5rLz5AZBIA
448
+ 461-Vanilla Ice - Ice Ice Baby (Official Music Video) rog8ou-ZepE
449
+ 462-Bryson Tiller - Don't (Explicit Version) d7cVLE4SaN0
450
+ 463-Michael Jackson - The Way You Make Me Feel (Official Video) HzZ_urpj4As
451
+ 464-Machine Gun Kelly, Camila Cabello - Bad Things (Official Music Video) QpbQ4I3Eidg
452
+ 465-Eminem - You Don't Know (Official Music Video) ft. 50 Cent, Cashis, Lloyd Banks ngH0fkiNo-g
453
+ 467-Kanye West - Stronger PsO6ZnUZI0g
454
+ 468-Bloodhound Gang - The Bad Touch (Official Video) xat1GVnl8-k
455
+ 469-What Goes Around...Comes Around (Official Video) TOrnUquxtwA
456
+ 470-Reyli Barba - Amor del Bueno (Video) FUinZg5MC5U
457
+ 471-Owl City & Carly Rae Jepsen - Good Time (Official Video) H7HmzwI67ec
458
+ 472-Plan B - Candy 9FWgcBfs5A0
459
+ 473-The Black Eyed Peas - Meet Me Halfway (Official Music Video) I7HahVwYpwo
460
+ 474-Lady Gaga - Judas (Official Music Video) wagn8Wrmzuc
461
+ 475-Justin Bieber - One Less Lonely Girl (Official Music Video) LXUSaVw3Mvk
462
+ 476-Lady Gaga - Applause (Official Music Video) pco91kroVgQ
463
+ 477-Rihanna - Rehab (Official Music Video) ft. Justin Timberlake rJYcmq__nDM
464
+ 478-Ricardo Montaner - La Gloria de Dios (Video Oficial) ft. Evaluna Montaner LRsgqFu5c1o
465
+ 479-Maître Gims - Est-ce que tu m'aimes (Clip officiel) 6TpyRE_juyA
466
+ 480-Michael Jackson - Bad (Shortened Version) dsUXAEzaC3Q
467
+ 481-Beyoncé - Best Thing I Never Had (Video) FHp2KgyQUFk
468
+ 482-Shawn Mendes, Camila Cabello - I Know What You Did Last Summer (Official Video) ngORmvyvAaI
469
+ 483-Drake - Take Care ft. Rihanna -zzP29emgpg
470
+ 484-One Direction - Steal My Girl UpsKGvPjAgw
471
+ 485-Selena Gomez - Slow Down (Official) Z8eXaXoUJRQ
472
+ 486-Jennifer Lopez - Booty ft. Iggy Azalea (Official Video) nxtIRArhVD4
473
+ 487-Demi Lovato - Cool for the Summer (Official Video) il9nqWw9W3Y
474
+ 488-Tove Lo - Habits (Stay High) oh2LWWORoiM
475
+ 489-WALK THE MOON - Shut Up and Dance (Official Video) 6JCLY0Rlx6Q
476
+ 490-One Direction - Little Things xGPeNN9S0Fg
477
+ 491-Big Sean - I Don't Fuck With You (Official Music Video) ft. E-40 cZaJYDPY-YQ
478
+ 492-Enrique Iglesias - No Me Digas Que No (Official Music Video) ft. Wisin & Yandel zyqt2avPkoA
479
+ 494-Taylor Swift - Everything Has Changed ft. Ed Sheeran w1oM3kQpXRo
480
+ 495-Britney Spears - Work B_ch (Official Music Video) pt8VYOfr8To
481
+ 496-Nacho - Bailame a1J44C-PZ3E
482
+ 497-Axel - Te Voy A Amar KZh60U1PqSE
483
+ 498-Route 94 - My Love (Official Video) ft. Jess Glynne BS46C2z5lVE
484
+ 499-Kendji Girac - Andalouse (Clip Officiel) FndmvPkI1Ms
485
+ 500-Little Mix - Touch (Official Video) gBAfejjUQoA
486
+ 501-Iggy Azalea - Work (Official Music Video) _zR6ROjoOX0
487
+ 502-Wisin & Yandel - Estoy Enamorado whBcmlaSLJM
488
+ 503-Alicia Keys - Girl on Fire (Official Video) J91ti_MpdHA
489
+ 504-Avril Lavigne - What The Hell (Official Music Video) tQmEd_UeeIk
490
+ 505-Zara Larsson - Uncover (Official Music Video) U-PXEe-qeK4
491
+ 506-Lady Gaga - Just Dance ft. Colby O'Donis (Official Music Video) ft. Colby O'Donis 2Abk1jAONjw
492
+ 507-Maluma - La Temperatura (Video) ft. Eli Palacios Tgt6iaSYMEM
493
+ 508-Akon - Sorry, Blame It On Me (Official Music Video) ynMk2EwRi4Q
494
+ 509-CNCO, Yandel - Hey DJ (Official Video) X6wQOW9ihDA
495
+ 510-Selena Gomez & The Scene - Naturally a_YR4dKArgo
496
+ 511-Eminem - Space Bound (Official Video) JByDbPn6A1o
497
+ 512-YG - My Nigga ft. Jeezy, Rich Homie Quan (Explicit) (Official Music Video) MSrTnWDTdwI
498
+ 513-August Alsina - No Love ft. Nicki Minaj nxvm4P0jFKY
499
+ 514-Farruko - Obsesionado (Official Video) lkN51aqPOzU
500
+ 515-Rihanna - Hate That I Love You ft. Ne-Yo KMOOr7GEkj8
501
+ 516-Madonna - Bitch I'm Madonna ft. Nicki Minaj 7hPMmzKs62w
502
+ 517-Selena Gomez & The Scene - Who Says BzE1mX4Px0I
503
+ 518-Ariana Grande - One Last Time (Official) BPgEgaPk62M
504
+ 519-Calvin Harris - Sweet Nothing (Official Video) ft. Florence Welch 17ozSeGw-fY
505
+ 520-Maroon 5 - Misery (Official Music Video) 6g6g2mvItp4
506
+ 521-Jay-Z & Kanye West - Ni_as In Paris (Explicit) gG_dA32oH44
507
+ 523-Beyoncé - Sorry (Video) QxsmWxxouIM
508
+ 524-The Weeknd - Reminder (Official Video) JZjAg6fK-BQ
509
+ 525-Pusho - Te Fuiste ft. Ozuna aZOGcaU7q1A
510
+ 526-Jeremih - Down On Me ft. 50 Cent (Official Music Video) AaXaig_43lU
511
+ 527-Jordin Sparks, Chris Brown - No Air (Official Video) ft. Chris Brown WBKnpyoFEBo
512
+ 528-Marc Anthony - Valio La Pena (Salsa Version) Ns9YYSqLxyI
513
+ 529-Prince Royce - Back It Up (Official Video) ft. Jennifer Lopez, Pitbull 9w9dXWU5nMI
514
+ 530-Eminem - Cleanin' Out My Closet (Official Music Video) RQ9_TKayu9s
515
+ 531-Chris Brown - Kiss Kiss ft. T-Pain eNII9PDlFJ0
516
+ 532-Avicii vs Nicky Romero - I Could Be The One (Nicktim) bek1y2uiQGA
517
+ 533-Jessie J - Domino (Official Video) UJtB55MaoD0
518
+ 534-Don Omar - Zumba Campaign Video 8HpG0l9cLos
519
+ 535-Britney Spears - Womanizer (Director's Cut) (Official HD Video) rMqayQ-U74s
520
+ 536-Demi Lovato - Confident (Official Video) cwLRQn61oUY
521
+ 537-Usher - DJ Got Us Fallin' In Love (Official Music Video) ft. Pitbull C-dvTjK_07c
522
+ 538-Beyoncé - Pretty Hurts (Video) LXXQLa-5n5w
523
+ 539-Akon - I Wanna Love You ft. Snoop Dogg GJzF7H2e3Tw
524
+ 540-Of Monsters And Men - Little Talks (Official Video) ghb6eDopW8I
525
+ 541-Enrique Iglesias - I Like It (Official Music Video) X9_n8jakvWU
526
+ 542-Michael Jackson, Justin Timberlake - Love Never Felt So Good (Official Video) oG08ukJPtR8
527
+ 543-Akon - Beautiful (Official Music Video) ft. Colby O'Donis, Kardinal Offishall rSOzN0eihsE
528
+ 544-Farruko - Sunset (Official Video) ft. Shaggy, Nicky Jam ZBMsSPR9QMg
529
+ 545-Ace Hood - Bugatti (Official Music Video) (Explicit) ft. Future, Rick Ross djE-BLrdDDc
530
+ 546-Jennifer Lopez - I'm Into You ft. Lil Wayne IgLcQmlN2Xg
531
+ 547-Calibre 50 - Contigo oeeNs3KInbc
532
+ 548-will.i.am - Feelin' Myself ft. Miley Cyrus, Wiz Khalifa, French Montana VRuoR--LdqQ
533
+ 549-Diddy - Dirty Money - Coming Home ft. Skylar Grey (Official Video) k-ImCpNqbJw
534
+ 550-Bon Jovi - You Give Love A Bad Name (Official Music Video) KrZHPOeOxQQ
535
+ 551-Chamillionaire - Ridin' (Official Music Video) ft. Krayzie Bone CtwJvgPJ9xw
536
+ 552-Zedd - Clarity ft. Foxes (Official Music Video) IxxstCcJlsc
537
+ 553-Justin Bieber - Confident ft. Chance The Rapper (Official Music Video) 47YClVMlthI
538
+ 554-Lana Del Rey - Blue Jeans JRWox-i6aAk
539
+ 555-blink-182 - I Miss You (Official Video) s1tAYmMjLdY
540
+ 556-Fergie - M.I.L.F. $ (Official Music Video) bsUWK-fixiA
541
+ 557-Taylor Swift - Mine XPBwXKgDTdE
542
+ 558-Three Days Grace - I Hate Everything About You (Official Video) d8ekz_CSBVg
543
+ 559-T.I. - About The Money ft. Young Thug (Official Music Video) etfIdtm-OC8
544
+ 560-will.i.am - This Is Love ft. Eva Simons (Official Music Video) 9I9Ar6upx34
545
+ 561-Kid Ink - Show Me (Explicit) ft. Chris Brown xKkb13IU_DE
546
+ 562-will.i.am - #thatPOWER ft. Justin Bieber (Official Music Video) DGIgXP9SvB8
547
+ 563-Marc Anthony - Ahora Quien (Salsa Version) toLrTToaN0M
548
+ 564-Future - Where Ya At ft. Drake lw3Or6eqIpI
549
+ 565-Taylor Swift - …Ready For It wIft-t-MQuE
550
+ 566-Young Money - Bed Rock (Official Music Video) Ha80ZaecGkQ
551
+ 567-Romeo Santos - Promise ft. Usher Y3XyWhrZnqE
552
+ 568-Chris Brown, Tyga - Ayo (Official Video) zKCrSN9oXgQ
553
+ 569-Hailee Steinfeld - Love Myself (Official Video) bMpFmHSgC4Q
554
+ 570-Justin Bieber - Never Let You Go (Official Music Video) 3ExWsVFJlFo
555
+ 571-Rihanna - California King Bed nhBorPm6JjQ
556
+ 572-Ways to Be Wicked (from Descendants 2) (Official Video) lX6g_cm2rM4
557
+ 573-Leona Lewis - Bleeding Love (US Version - Official Video) Vzo-EL_62fQ
558
+ 574-Labrinth - Beneath Your Beautiful (Official Video) ft. Emeli Sandé bqIxCtEveG8
559
+ 575-Marc Anthony - A Quién Quiero Mentirle (Video) GeApuPcMVeQ
560
+ 576-Chris Brown - Next To You (Official Music Video) ft. Justin Bieber EEuQU6a90Pc
561
+ 577-Sia - Big Girls Cry (Official Video) 4NhKWZpkw1Q
562
+ 578-Shakira - She Wolf (Official HD Video) booKP974B0k
563
+ 579-Jay Sean - Down ft. Lil Wayne (Official Music Video) oUbpGmR1-QM
564
+ 581-Avicii - Addicted To You Qc9c12q3mrc
565
+ 582-Pitbull - Hotel Room Service (Official Video) 2up_Eq6r6Ko
566
+ 583-Lady Gaga - Paparazzi (Official Music Video) d2smz_1L2_0
567
+ 584-Chris Brown - Yeah 3x 3mC2ixOAivA
568
+ 585-Nick Jonas - Close ft. Tove Lo XgJFqVvb2Ws
569
+ 586-Hailee Steinfeld, Grey - Starving ft. Zedd (Official Video) xwjwCFZpdns
570
+ 587-Ne-Yo - One In A Million (Official Music Video) 6tpl9LtkRRw
571
+ 588-Lady Gaga - Born This Way (Official Music Video) wV1FrqwZyKw
572
+ 589-Chris Brown - Turn Up the Music eQWG8BVeryU
573
+ 590-Juan Magan - Si No Te Quisiera ft. Belinda, Lapiz Conciente XoNCV9BsU9c
574
+ 591-Katy Perry - Teenage Dream (Official Music Video) 98WtmW-lfeE
575
+ 592-Cher Lloyd - Want U Back (US Version) (Official Music Video) LPgvNlrBfb0
576
+ 593-Shakira - Addicted to You MntbN1DdEP0
577
+ 594-Sebastián Yatra - Alguien Robó ft. Wisin, Nacho EH0Wg8SaITQ
578
+ 595-Chris Brown - Forever (Official HD Video) 5sMKX22BHeE
579
+ 596-Snow Patrol - Chasing Cars (Official Video) GemKqzILV4w
580
+ 597-Lil Wayne - Drop The World ft. Eminem (Official Music Video) ft. Eminem ErCAOMi5EGM
581
+ 598-Miley Cyrus - 7 Things (Official Video) Hr0Wv5DJhuk
582
+ 599-Matheus & Kauan - O Nosso Santo Bateu – Na Praia Ao Vivo kbCtpDwVCLQ
583
+ 600-Maejor Ali - Lolly ft. Juicy J, Justin Bieber BiOmXeKyrxo
584
+ 601-Kings Of Leon - Use Somebody (Official Video) gnhXHvRoUd0
585
+ 602-Pitbull - Fireball ft. John Ryan HMqgVXSvwGo
586
+ 603-Calvin Harris - Feel So Close (Official Video) dGghkjpNCQ8
587
+ 604-Carly Rae Jepsen - I Really Like You qV5lzRHrGeg
588
+ 605-Demi Lovato - Skyscraper (Official Video) r_8ydghbGSg
589
+ 606-Keri Hilson - Knock You Down (Official Music Video) ft. Kanye West, Ne-Yo p_RqWocthcc
590
+ 607-Wisin & Yandel - Te Siento SKWxOsbt9gU
591
+ 608-The Black Eyed Peas - Just Can't Get Enough (Official Music Video) OrTyD7rjBpw
592
+ 609-Jennifer Lopez - Live It Up ft. Pitbull BofL1AaiTjo
593
+ 610-Eminem - Just Lose It (Official Music Video) 9dcVOmEQzKA
594
+ 612-The Black Eyed Peas - Don't Stop The Party (Official Music Video) u9LH_y159sg
595
+ 613-Tinie Tempah - Written In The Stars ft. Eric Turner YgFyi74DVjc
596
+ 614-Big Sean - Blessings (Official Explicit Video) ft. Drake, Kanye West M6t47RI4bns
597
+ 615-Britney Spears - I Wanna Go (Official Video) T-sxSd1uwoU
598
+ 616-Rihanna - Russian Roulette (Official Music Video) ZQ2nCGawrSY
599
+ 617-Ellie Goulding - On My Mind (Official Video) H202k7KfZL0
600
+ 618-Pitbull - Hey Baby (Drop It To The Floor) ft. T-Pain LefQdEMJP1I
601
+ 619-Maître Gims - J'me tire (Clip officiel) F_rEHfLgdcY
602
+ 620-LMFAO - Champagne Showers ft. Natalia Kills UA8rcLvS1BY
603
+ 621-Nicki Minaj - Pound The Alarm (Explicit) vdrqA93sW-8
604
+ 622-Maluma - La Curiosidad 9t7eMteW-Tc
605
+ 623-Shakira - Rabiosa (English Version) ft. Pitbull a5irTX82olg
606
+ 624-Rich Homie Quan - Type of Way (Official Video) -KKbdErJkiY
607
+ 625-P!nk - Just Like Fire (From'Alice Through The Looking Glass' - Official Video) 5Nrv5teMc9Y
608
+ 626-Rihanna - What Now (Official) b-3BI9AspYc
609
+ 627-Camila - De Que Me Sirve la Vida 3YhoejhnW8w
610
+ 628-Jennifer Lopez - Goin' In ft. Flo Rida z5W7DVFKrcs
611
+ 629-LMFAO ft. Lil Jon - Shots (Official Video) XNtTEibFvlQ
612
+ 630-Ciara - Like A Boy (Official Video) _HKH7Emy1SY
613
+ 631-Calvin Harris & Alesso - Under Control (Official Video) ft. Hurts yZqmarGShxg
614
+ 632-Fifth Harmony - BO$$ (BOSS) Y4JfPlry-iQ
615
+ 633-Eminem - Berzerk (Official Music Video) (Explicit) ab9176Srb5Y
616
+ 634-Years & Years - King (Official Video) g_uoH6hJilc
617
+ 635-Ne-Yo - So Sick (Official Music Video) IxszlJppRQI
618
+ 636-Selena Gomez & The Scene - A Year Without Rain M8uPvX2te0I
619
+ 637-Daddy Yankee - Sabado Rebelde ft. Plan B 0nPkXDrL2ZU
620
+ 638-Kanye West - All Of The Lights ft. Rihanna, Kid Cudi HAfFfqiYLp0
621
+ 639-Zedd - Stay The Night ft. Hayley Williams (Official Music Video) i-gyZ35074k
622
+ 640-Yandel - Como Antes (Official Video) ft. Wisin QeaumjX9DNY
623
+ 641-Taylor Swift - Back To December QUwxKWT6m7U
624
+ 642-Romeo Santos - Rival (Official Video) ft. Mario Domm 6vMhhBRj-2Q
625
+ 643-Henrique & Diego - Suíte 14 (Ao Vivo) ft. Mc Guimê gmvFLIuVAbA
626
+ 644-Britney Spears - Gimme More (Official HD Video) elueA2rofoo
627
+ 645-Rihanna - You Da One b3HeLs8Yosw
628
+ 646-Avicii - Hey Brother 6Cp6mKbRTQY
629
+ 647-Soulja Boy Tell'em ft. Sammie - Kiss Me Thru The Phone (Official Video) 47Fbo4kU2AU
630
+ 648-Beyoncé - Partition (Explicit Video) pZ12_E5R3qc
631
+ 649-Kid Cudi - Pursuit Of Happiness (Official Music Video) ft. MGMT 7xzU9Qqdqww
632
+ 650-Sigala - Sweet Lovin' ft. Bryn Christopher (Official Video) qj5zT4t7S6c
633
+ 651-The Game - My Life ft. Lil Wayne (Official Music Video) udxZ9zkDzpo
634
+ 652-Nicki Minaj - Moment 4 Life (Clean Version) (Official Music Video) ft. Drake D7GW8TYCEG4
635
+ 653-Nicki Minaj - High School (Explicit) ft. Lil Wayne RnpyRe_7jZA
636
+ 654-Chino & Nacho - Niña Bonita Oe1fRwgGu5E
637
+ 655-Far East Movement ft. The Cataracs, DEV - Like A G6 (Official Video) w4s6H4ku6ZY
638
+ 656-Pitbull, Ne-Yo - Time Of Our Lives bTXJQ5ql5Fw
639
+ 657-Lorde - Team f2JuxM-snGc
640
+ 658-Christina Aguilera - Candyman (Official Music Video) -ScjucUV8v0
641
+ 659-Katy Perry - I Kissed A Girl (Official) tAp9BKosZXs
642
+ 660-One Direction - Gotta Be You nvfejaHz-o0
643
+ 661-Nicki Minaj - Pills N Potions (Official) f7ld-3nZUxA
644
+ 662-Mohombi - Bumpy Ride G2RCCDSBEGk
645
+ 663-Demi Lovato - Neon Lights (Official Video) v9uDwppN5-w
646
+ 664-The Pussycat Dolls - When I Grow Up (Official Music Video) K0K46C82v9o
647
+ 665-Chris Brown - Don't Wake Me Up (Official Music Video) QOowQeKyNkQ
648
+ 666-Christina Aguilera - Hurt (Main Video) wwCykGDEp7M
649
+ 667-Eminem - We Made You (Official Music Video) RSdKmX2BH7o
650
+ 668-Taio Cruz - Break Your Heart (Official Video) ft. Ludacris y_SI2EDM6Lo
651
+ 669-Demi Lovato - Really Don't Care ft. Cher Lloyd (Official Video) OJGUbwVMBeA
652
+ 670-P!nk - Raise Your Glass (Official Video) XjVNlG5cZyQ
653
+ 671-Austin Mahone - Mmm Yeah ft. Pitbull MMAppa1cAVo
654
+ 672-Avril Lavigne - Smile (Official Music Video) KagvExF-ijc
655
+ 673-Little Mix - Wings (Official Video) cOQDsmEqVt8
656
+ 674-Brandon Beal - Twerk It Like Miley - Produced by Hedegaard ft. Christopher PLE57UZievU
657
+ 675-El Bebeto - No Te Creas Tan Importante (Video Oficial) nMv2PeG-2mc
658
+ 676-Eminem - My Name Is (Official Music Video) sNPnbI1arSE
659
+ 677-Justin Bieber - All That Matters JC2yu2a9sHk
660
+ 678-The Wanted - Glad You Came 2ggzxInyzVE
661
+ 679-Maluma - Addicted (Official Music Video) pMIHC_cItd4
662
+ 680-Pitbull - Fun (Official Video) ft. Chris Brown jKbR7u8J5PU
663
+ 681-Thalia - Desde Esa Noche (Official Video) ft. Maluma CkyBXdXkMr8
664
+ 682-Michael Jackson - You Rock My World (Official Video) 1-7ABIM2qjU
665
+ 683-The Band Perry - If I Die Young (Official Video) 7NJqUN9TClM
666
+ 684-Alessia Cara - Here (Official Video) UKp2CrfmVfw
667
+ 685-Güliz Ayla - Olmazsan Olmaz j-T4hRJNFJI
668
+ 686-Rihanna - Disturbia E1mU6h4Xdxc
669
+ 687-Beyoncé - Diva rNM5HW13_O8
670
+ 688-Bridgit Mendler - Ready or Not (Official Video) dPKG1-3LXBs
671
+ 689-Nicki Minaj - Beez In The Trap (Explicit) ft. 2 Chainz EmZvOhHF85I
672
+ 691-Snoop Dogg - 'Sweat' Snoop Dogg vs David Guetta (Remix) [Official Video] KnEXrbAQyIo
673
+ 692-Olly Murs - Troublemaker ft. Flo Rida 4aQDOUbErNg
674
+ 693-Ciara ft. Ludacris - Ride (Official Video) Lp6W4aK1sbs
675
+ 694-Chris Brown - Don't Judge Me z29nI8RQV0U
676
+ 695-Kendrick Lamar - LOYALTY. ft. Rihanna Dlh-dzB2U4Y
677
+ 696-Chris Brown - Love More (Explicit) ft. Nicki Minaj Tff2oE31Mlw
678
+ 697-Christina Aguilera - Your Body (Official Music Video) (Clean Version) 6cfCgLgiFDM
679
+ 699-MIKA - Popular Song ft. Ariana Grande nmcdLOjGVzw
680
+ 700-Britney Spears - Till The World Ends (Official Video) qzU9OrZlKb8
681
+ 701-Zendaya - Replay cyLE48i4XY0
682
+ 702-Shontelle - Impossible (Official Video) NWdrO4BoCu8
683
+ 703-Nicki Minaj, Cassie - The Boys (Explicit) kXFcr6oy5dk
684
+ 704-Miley Cyrus - Can't Be Tamed (Official Video) sjSG6z_13-Q
685
+ 705-Little Mix - Move (Official Video) RwD4eJGxPc4
686
+ 706-Selena Gomez - Tell Me Something I Don't Know _RRyniZG0Jo
687
+ 707-Britney Spears - Circus (Official HD Video) lVhJ_A8XUgc
688
+ 708-Avril Lavigne - Here's to Never Growing Up sXd2WxoOP5g
689
+ 709-Lady Gaga - LoveGame (Official Music Video) 1mB0tP1I-14
690
+ 710-Chris Brown - Gimme That (remix) ft. Lil Wayne 3yl-5FOZcr0
691
+ 711-Beyoncé - Sweet Dreams JlxByc0-V40
692
+ 712-Leona Lewis - Bleeding Love (Official Video) 7_weSk0BonM
693
+ 713-Taio Cruz - Dynamite (Official Video) VUjdiDeJ0xg
694
+ 714-Tinashe - 2 On (Explicit) ft. SchoolBoy Q -s7TCuCpB5c
695
+ 715-Natalie La Rose - Somebody ft. Jeremih 8zqdo_Umd5c
696
+ 717-Usher - OMG ft. will.i.am 1RnPB76mjxI
697
+ 718-Taylor Swift - Our Song Jb2stN7kH28
698
+ 719-Lil Wayne - How To Love (Official Music Video) y8Gf4-eT3w0
699
+ 720-Nicole Scherzinger - Right There ft. 50 Cent t-vTaktsUSw
700
+ 721-OneRepublic - Good Life (Official Music Video) jZhQOvvV45w
701
+ 722-Britney Spears, Iggy Azalea - Pretty Girls (Official Video) uV2uebhnqOw
702
+ 723-Ellie Goulding - Lights (Official Video) 0NKUpo_xKyQ
703
+ 724-Miley Cyrus - Adore You (Official Video) W1tzURKYFNs
704
+ 725-Kanye West - Heartless Co0tTeuUVhU
705
+ 726-Rihanna - Te Amo (Official Music Video) Oe4Ic7fHWf8
706
+ 727-Ariana Grande - Baby I bJuWlMFToNo
707
+ 728-Vanessa Hudgens - Say Ok (Official Music Video) F5VvvVxuKko
708
+ 729-DJ Khaled - I'm On One (Explicit Version) ft. Drake, Rick Ross, Lil Wayne Z09lYqdxqzo
709
+ 730-Demi Lovato - Made in the USA (Official Video) z3zdIHDTbg0
710
+ 731-Train - Drive By (Official Music Video) oxqnFJ3lp5k
711
+ 732-Eminem - The Way I Am (Official Music Video) mQvteoFiMlg
712
+ 733-Timbaland - Carry Out (Official Music Video) ft. Justin Timberlake NRdHsuuXxfk
713
+ 734-Daddy Yankee - La Noche De Los Dos ft. Natalia Jiménez GDBaeQ5JPuU
714
+ 735-Justin Bieber - U Smile (Official Music Video) r2ozuCXpVJY
715
+ 736-Ke$ha - Die Young (Official) NOubzHCUt48
716
+ 737-Nick Jonas - Jealous yw04QD1LaB0
717
+ 739-Ariana Grande - Right There ft. Big Sean fhcpubAVdmc
718
+ 740-Selena Gomez & The Scene - Hit The Lights 8c2ahBlTPz0
719
+ 741-Eminem - Survival (Explicit) NlmezywdxPI
720
+ 742-Miley Cyrus - Who Owns My Heart (Official Video) iVbQxC2c3-8
721
+ 743-Rihanna - Cheers (Drink To That) ZR0v0i63PQ4
722
+ 744-Sigala - Easy Love (Official Music Video) ozx898ADTxM
723
+ 745-Farruko - Besas Tan Bien (Official Video) E-kkX2UuBcg
724
+ 746-OneRepublic - All The Right Moves (Official Music Video) qrOeGCJdZe4
725
+ 747-Enrique Iglesias, Usher - Dirty Dancer ft. Lil Wayne vHJAUuicC0Q
726
+ 748-Austin Mahone - What About Love (Official Video) 2PEG82Udb90
727
+ 749-Rihanna - Hard (Official Music Video) ft. Jeezy Xcwd_Nz6Zog
728
+ 750-Lady Gaga - Perfect Illusion (Official Music Video) Xn599R0ZBwg
729
+ 752-MGMT - Electric Feel (Official HD Video) MmZexg8sxyk
730
+ 753-'Weird Al' Yankovic - White & Nerdy (Official Music Video) N9qYF9DZPdw
731
+ 754-Taylor Swift - White Horse D1Xr-JFLxik
732
+ 755-Miley Cyrus - When I Look At You (Official Video) 8wxOVn99FTE
733
+ 756-Ne-Yo - Let Me Love You (Until You Learn To Love Yourself) (Official Music Video) crrOl0egI00
734
+ 757-Cher Lloyd - Oath (Official Music Video) ft. Becky G Cqz713hhz1Y
735
+ 758-Timbaland - If We Ever Meet Again ft. Katy Perry (Official Music Video) KDKva-s_khY
736
+ 759-'Watch Me' from Disney Channel's 'Shake It Up' (Official Video) PPNMGYOm1aM
737
+ 761-Taio Cruz - Hangover (Official Video) ft. Flo Rida dLhFDYQHDQY
738
+ 762-Daddy Yankee - Ven Conmigo ft. Prince Royce ZEInlYjVFzk
739
+ 765-Demi Lovato - La La Land (Official Music Video) nmjO1p9Oxrk
740
+ 766-Selena Gomez & The Scene - Round & Round UfcvO2t8Ntg
741
+ 767-Britney Spears - Hold It Against Me (Official Video) -Edv8Onsrgg
742
+ 768-Far East Movement - Turn Up The Love ft. Cover Drive UqXVgAmqBOs
743
+ 769-Justin Bieber - Pray (Official Music Video) o9tJW9MDs2M
744
+ 770-Drake - Find Your Love (Official Music Video) Xyv4Bjja8yc
745
+ 772-Nicki Minaj - Va Va Voom (Explicit) 3U72hzeBLOw
746
+ 773-will.i.am, Nicki Minaj - Check It Out (Official Music Video) pqky5B179nM
747
+ 774-Nicki Minaj - Stupid Hoe (Explicit) T6j4f8cHBIM
748
+ 775-Jennifer Lopez ft. French Montana - I Luh Ya Papi (Explicit) [Official Video] c4oiEhf9M04
dataset/vevo_meta/top_chord.txt ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ C 1 32576
2
+ A:min 122 31898
3
+ F 66 22538
4
+ G 92 22137
5
+ E:min 57 7935
6
+ D:min 31 6457
7
+ D 27 3973
8
+ A:min7 121 3846
9
+ A 118 3606
10
+ E 53 2613
11
+ D:min7 30 2598
12
+ F:maj7 78 2530
13
+ A# 131 1854
14
+ E:min7 56 1695
15
+ E:7 63 1396
16
+ G:7 102 1321
17
+ C:maj7 13 1039
18
+ C:7 11 791
19
+ D:7 37 697
20
+ G:min 96 685
21
+ C:min 5 684
22
+ B:min 148 528
23
+ F:min 70 474
24
+ B 144 459
25
+ D# 40 459
26
+ G# 105 452
27
+ A:7 128 391
28
+ F:7 76 384
29
+ G:sus4 94 384
30
+ G:min7 95 277
default_sound_font.sf2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74594e8f4250680adf590507a306655a299935343583256f3b722c48a1bc1cb0
3
+ size 148398306
model/__pycache__/music_transformer.cpython-37.pyc ADDED
Binary file (5.14 kB). View file
 
model/__pycache__/positional_encoding.cpython-37.pyc ADDED
Binary file (1.18 kB). View file
 
model/__pycache__/positional_encoding.cpython-38.pyc ADDED
Binary file (1.19 kB). View file
 
model/__pycache__/rpr.cpython-37.pyc ADDED
Binary file (11 kB). View file
 
model/__pycache__/rpr.cpython-38.pyc ADDED
Binary file (11 kB). View file
 
model/__pycache__/video_music_transformer.cpython-37.pyc ADDED
Binary file (5.51 kB). View file
 
model/__pycache__/video_music_transformer.cpython-38.pyc ADDED
Binary file (5.65 kB). View file
 
model/__pycache__/video_regression.cpython-37.pyc ADDED
Binary file (2.08 kB). View file
 
model/__pycache__/video_regression.cpython-38.pyc ADDED
Binary file (2.16 kB). View file
 
model/loss.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import torch.nn.functional as F
4
+ from torch.nn.modules.loss import _Loss
5
+
6
+ # Borrowed from https://github.com/jason9693/MusicTransformer-pytorch/blob/5f183374833ff6b7e17f3a24e3594dedd93a5fe5/custom/criterion.py#L28
7
+ class SmoothCrossEntropyLoss(_Loss):
8
+ """
9
+ https://arxiv.org/abs/1512.00567
10
+ """
11
+ __constants__ = ['label_smoothing', 'vocab_size', 'ignore_index', 'reduction']
12
+
13
+ def __init__(self, label_smoothing, vocab_size, ignore_index=-100, reduction='mean', is_logits=True):
14
+ assert 0.0 <= label_smoothing <= 1.0
15
+ super().__init__(reduction=reduction)
16
+
17
+ self.label_smoothing = label_smoothing
18
+ self.vocab_size = vocab_size
19
+ self.ignore_index = ignore_index
20
+ self.input_is_logits = is_logits
21
+
22
+ def forward(self, input, target):
23
+ """
24
+ Args:
25
+ input: [B * T, V]
26
+ target: [B * T]
27
+ Returns:
28
+ cross entropy: [1]
29
+ """
30
+ mask = (target == self.ignore_index).unsqueeze(-1)
31
+ q = F.one_hot(target.long(), self.vocab_size).type(torch.float32)
32
+ u = 1.0 / self.vocab_size
33
+ q_prime = (1.0 - self.label_smoothing) * q + self.label_smoothing * u
34
+ q_prime = q_prime.masked_fill(mask, 0)
35
+
36
+ ce = self.cross_entropy_with_logits(q_prime, input)
37
+ if self.reduction == 'mean':
38
+ lengths = torch.sum(target != self.ignore_index)
39
+ return ce.sum() / lengths
40
+ elif self.reduction == 'sum':
41
+ return ce.sum()
42
+ else:
43
+ raise NotImplementedError
44
+
45
+ def cross_entropy_with_logits(self, p, q):
46
+ return -torch.sum(p * (q - q.logsumexp(dim=-1, keepdim=True)), dim=-1)
model/music_transformer.py ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ from torch.nn.modules.normalization import LayerNorm
4
+ import random
5
+
6
+ from utilities.constants import *
7
+ from utilities.device import get_device
8
+
9
+ from .positional_encoding import PositionalEncoding
10
+ from .rpr import TransformerEncoderRPR, TransformerEncoderLayerRPR
11
+ import json
12
+ # MusicTransformer
13
+ class MusicTransformer(nn.Module):
14
+ def __init__(self, n_layers=6, num_heads=8, d_model=512, dim_feedforward=1024,
15
+ dropout=0.1, max_sequence_midi=2048, max_sequence_chord=300, rpr=False):
16
+ super(MusicTransformer, self).__init__()
17
+
18
+ self.dummy = DummyDecoder()
19
+ self.nlayers = n_layers
20
+ self.nhead = num_heads
21
+ self.d_model = d_model
22
+ self.d_ff = dim_feedforward
23
+ self.dropout = dropout
24
+ self.max_seq_midi = max_sequence_midi
25
+ self.max_seq_chord = max_sequence_chord
26
+ self.rpr = rpr
27
+
28
+ # Input embedding for video and music features
29
+ self.embedding = nn.Embedding(CHORD_SIZE, self.d_model)
30
+
31
+ # self.embedding_key = nn.Embedding(1, self.d_model)
32
+ self.embedding_root = nn.Embedding(CHORD_ROOT_SIZE, self.d_model)
33
+ self.embedding_attr = nn.Embedding(CHORD_ATTR_SIZE, self.d_model)
34
+
35
+ self.positional_encoding = PositionalEncoding(self.d_model, self.dropout, self.max_seq_chord)
36
+ self.Linear_chord = nn.Linear(self.d_model+1, self.d_model)
37
+
38
+ # Base transformer
39
+ if(not self.rpr):
40
+ self.transformer = nn.Transformer(
41
+ d_model=self.d_model, nhead=self.nhead, num_encoder_layers=self.nlayers,
42
+ num_decoder_layers=0, dropout=self.dropout, # activation=self.ff_activ,
43
+ dim_feedforward=self.d_ff, custom_decoder=self.dummy
44
+ )
45
+ # RPR Transformer
46
+ else:
47
+ encoder_norm = LayerNorm(self.d_model)
48
+ encoder_layer = TransformerEncoderLayerRPR(self.d_model, self.nhead, self.d_ff, self.dropout, er_len=self.max_seq_chord)
49
+
50
+ encoder = TransformerEncoderRPR(encoder_layer, self.nlayers, encoder_norm)
51
+ self.transformer = nn.Transformer(
52
+ d_model=self.d_model, nhead=self.nhead, num_encoder_layers=self.nlayers,
53
+ num_decoder_layers=0, dropout=self.dropout, # activation=self.ff_activ,
54
+ dim_feedforward=self.d_ff, custom_decoder=self.dummy, custom_encoder=encoder
55
+ )
56
+ # Final output is a softmaxed linear layer
57
+ self.Wout = nn.Linear(self.d_model, CHORD_SIZE)
58
+ self.Wout_root = nn.Linear(self.d_model, CHORD_ROOT_SIZE)
59
+ self.Wout_attr = nn.Linear(self.d_model, CHORD_ATTR_SIZE)
60
+ self.softmax = nn.Softmax(dim=-1)
61
+
62
+ # forward
63
+ def forward(self, x, x_root, x_attr, feature_key, mask=True):
64
+ if(mask is True):
65
+ mask = self.transformer.generate_square_subsequent_mask(x.shape[1]).to(get_device())
66
+ else:
67
+ mask = None
68
+
69
+ ### Chord + Key (DECODER) ###
70
+ # x = self.embedding(x)
71
+
72
+ x_root = self.embedding_root(x_root)
73
+ x_attr = self.embedding_attr(x_attr)
74
+ x = x_root + x_attr
75
+
76
+ feature_key_padded = torch.full((x.shape[0], x.shape[1], 1), feature_key.item())
77
+ feature_key_padded = feature_key_padded.to(get_device())
78
+ x = torch.cat([x, feature_key_padded], dim=-1)
79
+ xf = self.Linear_chord(x)
80
+
81
+ ### POSITIONAL ENCODING ###
82
+ xf = xf.permute(1,0,2) # -> (max_seq-1, batch_size, d_model)
83
+ xf = self.positional_encoding(xf)
84
+
85
+ ### TRANSFORMER ###
86
+ x_out = self.transformer(src=xf, tgt=xf, tgt_mask=mask)
87
+ x_out = x_out.permute(1,0,2)
88
+
89
+ if IS_SEPERATED:
90
+ y_root = self.Wout_root(x_out)
91
+ y_attr = self.Wout_attr(x_out)
92
+ del mask
93
+ return y_root, y_attr
94
+ else:
95
+ y = self.Wout(x_out)
96
+ del mask
97
+ return y
98
+
99
+ # generate
100
+ def generate(self, feature_key=None, primer=None, primer_root=None, primer_attr=None, target_seq_length=300, beam=0, beam_chance=1.0):
101
+ assert (not self.training), "Cannot generate while in training mode"
102
+
103
+ with open('dataset/vevo_meta/chord_inv.json') as json_file:
104
+ chordInvDic = json.load(json_file)
105
+ with open('dataset/vevo_meta/chord_root.json') as json_file:
106
+ chordRootDic = json.load(json_file)
107
+ with open('dataset/vevo_meta/chord_attr.json') as json_file:
108
+ chordAttrDic = json.load(json_file)
109
+
110
+ print("Generating sequence of max length:", target_seq_length)
111
+ gen_seq = torch.full((1,target_seq_length), CHORD_PAD, dtype=TORCH_LABEL_TYPE, device=get_device())
112
+ gen_seq_root = torch.full((1,target_seq_length), CHORD_ROOT_PAD, dtype=TORCH_LABEL_TYPE, device=get_device())
113
+ gen_seq_attr = torch.full((1,target_seq_length), CHORD_ATTR_PAD, dtype=TORCH_LABEL_TYPE, device=get_device())
114
+
115
+ num_primer = len(primer)
116
+
117
+ gen_seq[..., :num_primer] = primer.type(TORCH_LABEL_TYPE).to(get_device())
118
+ gen_seq_root[..., :num_primer] = primer_root.type(TORCH_LABEL_TYPE).to(get_device())
119
+
120
+ gen_seq_attr[..., :num_primer] = primer_attr.type(TORCH_LABEL_TYPE).to(get_device())
121
+
122
+ cur_i = num_primer
123
+ while(cur_i < target_seq_length):
124
+ # gen_seq_batch = gen_seq.clone()
125
+ # y = self.softmax(self.forward(gen_seq[..., :cur_i]))[..., :CHORD_END]
126
+ y = self.softmax( self.forward( gen_seq[..., :cur_i], gen_seq_root[..., :cur_i], gen_seq_attr[..., :cur_i], feature_key) )[..., :CHORD_END]
127
+
128
+ token_probs = y[:, cur_i-1, :]
129
+ if(beam == 0):
130
+ beam_ran = 2.0
131
+ else:
132
+ beam_ran = random.uniform(0,1)
133
+ if(beam_ran <= beam_chance):
134
+ token_probs = token_probs.flatten()
135
+ top_res, top_i = torch.topk(token_probs, beam)
136
+ beam_rows = top_i // CHORD_SIZE
137
+ beam_cols = top_i % CHORD_SIZE
138
+ gen_seq = gen_seq[beam_rows, :]
139
+ gen_seq[..., cur_i] = beam_cols
140
+ else:
141
+ distrib = torch.distributions.categorical.Categorical(probs=token_probs)
142
+ next_token = distrib.sample()
143
+ #print("next token:",next_token)
144
+ gen_seq[:, cur_i] = next_token
145
+ gen_chord = chordInvDic[ str( next_token.item() ) ]
146
+
147
+ chord_arr = gen_chord.split(":")
148
+ if len(chord_arr) == 1:
149
+ chordRootID = chordRootDic[chord_arr[0]]
150
+ chordAttrID = 1
151
+ chordRootID = torch.tensor([chordRootID]).to(get_device())
152
+ chordAttrID = torch.tensor([chordAttrID]).to(get_device())
153
+ gen_seq_root[:, cur_i] = chordRootID
154
+ gen_seq_attr[:, cur_i] = chordAttrID
155
+ elif len(chord_arr) == 2:
156
+ chordRootID = chordRootDic[chord_arr[0]]
157
+ chordAttrID = chordAttrDic[chord_arr[1]]
158
+ chordRootID = torch.tensor([chordRootID]).to(get_device())
159
+ chordAttrID = torch.tensor([chordAttrID]).to(get_device())
160
+ gen_seq_root[:, cur_i] = chordRootID
161
+ gen_seq_attr[:, cur_i] = chordAttrID
162
+
163
+ # Let the transformer decide to end if it wants to
164
+ if(next_token == CHORD_END):
165
+ print("Model called end of sequence at:", cur_i, "/", target_seq_length)
166
+ break
167
+
168
+ cur_i += 1
169
+ if(cur_i % 50 == 0):
170
+ print(cur_i, "/", target_seq_length)
171
+ return gen_seq[:, :cur_i]
172
+
173
+ class DummyDecoder(nn.Module):
174
+ def __init__(self):
175
+ super(DummyDecoder, self).__init__()
176
+ def forward(self, tgt, memory, tgt_mask, memory_mask,tgt_key_padding_mask,memory_key_padding_mask):
177
+ return memory
model/positional_encoding.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import math
4
+
5
+ # PositionalEncoding
6
+ # Taken from https://pytorch.org/tutorials/beginner/transformer_tutorial.html
7
+ class PositionalEncoding(nn.Module):
8
+
9
+ def __init__(self, d_model, dropout=0.1, max_len=5000):
10
+ super(PositionalEncoding, self).__init__()
11
+ self.dropout = nn.Dropout(p=dropout)
12
+
13
+ pe = torch.zeros(max_len, d_model)
14
+ position = torch.arange(0, max_len, dtype=torch.float).unsqueeze(1)
15
+ div_term = torch.exp(torch.arange(0, d_model, 2).float() * (-math.log(10000.0) / d_model))
16
+ pe[:, 0::2] = torch.sin(position * div_term)
17
+ pe[:, 1::2] = torch.cos(position * div_term)
18
+ pe = pe.unsqueeze(0).transpose(0, 1)
19
+ self.register_buffer('pe', pe)
20
+
21
+ def forward(self, x):
22
+ x = x + self.pe[:x.size(0), :]
23
+ return self.dropout(x)
model/rpr.py ADDED
@@ -0,0 +1,455 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+
4
+ from torch.nn import functional as F
5
+ from torch.nn.parameter import Parameter
6
+ from torch.nn import Module
7
+ from torch.nn.modules.transformer import _get_clones
8
+ from torch.nn.modules.linear import Linear
9
+ from torch.nn.modules.dropout import Dropout
10
+ from torch.nn.modules.normalization import LayerNorm
11
+ from torch.nn.init import *
12
+
13
+ from torch.nn.functional import linear, softmax, dropout
14
+ from torch.nn import MultiheadAttention
15
+ from typing import Optional
16
+
17
+ class TransformerDecoderRPR(Module):
18
+ def __init__(self, decoder_layer, num_layers, norm=None):
19
+ super(TransformerDecoderRPR, self).__init__()
20
+ self.layers = _get_clones(decoder_layer, num_layers)
21
+ self.num_layers = num_layers
22
+ self.norm = norm
23
+
24
+ def forward(self, tgt, memory, tgt_mask=None, memory_mask=None, tgt_key_padding_mask=None, memory_key_padding_mask=None):
25
+ output = tgt
26
+ for mod in self.layers:
27
+ output = mod(output, memory, tgt_mask=tgt_mask,
28
+ memory_mask=memory_mask,
29
+ tgt_key_padding_mask=tgt_key_padding_mask,
30
+ memory_key_padding_mask=memory_key_padding_mask)
31
+
32
+ if self.norm is not None:
33
+ output = self.norm(output)
34
+
35
+ return output
36
+
37
+ class TransformerDecoderLayerRPR(Module):
38
+ def __init__(self, d_model, nhead, dim_feedforward=2048, dropout=0.1, er_len=None):
39
+ super(TransformerDecoderLayerRPR, self).__init__()
40
+
41
+ self.self_attn = MultiheadAttentionRPR(d_model, nhead, dropout=dropout, er_len=er_len)
42
+ self.multihead_attn = MultiheadAttention(d_model, nhead, dropout=dropout)
43
+ # Implementation of Feedforward model
44
+ self.linear1 = Linear(d_model, dim_feedforward)
45
+ self.dropout = Dropout(dropout)
46
+ self.linear2 = Linear(dim_feedforward, d_model)
47
+
48
+ self.norm1 = LayerNorm(d_model)
49
+ self.norm2 = LayerNorm(d_model)
50
+ self.norm3 = LayerNorm(d_model)
51
+ self.dropout1 = Dropout(dropout)
52
+ self.dropout2 = Dropout(dropout)
53
+ self.dropout3 = Dropout(dropout)
54
+
55
+ def forward(self, tgt, memory, tgt_mask=None, memory_mask=None,
56
+ tgt_key_padding_mask=None, memory_key_padding_mask=None):
57
+ tgt2 = self.self_attn(tgt, tgt, tgt, attn_mask=tgt_mask,
58
+ key_padding_mask=tgt_key_padding_mask)[0]
59
+ tgt = tgt + self.dropout1(tgt2)
60
+ tgt = self.norm1(tgt)
61
+
62
+ tgt2 = self.multihead_attn(tgt, memory, memory, attn_mask=memory_mask,
63
+ key_padding_mask=memory_key_padding_mask)[0]
64
+
65
+ tgt = tgt + self.dropout2(tgt2)
66
+ tgt = self.norm2(tgt)
67
+ tgt2 = self.linear2(self.dropout(F.relu(self.linear1(tgt))))
68
+ tgt = tgt + self.dropout3(tgt2)
69
+ tgt = self.norm3(tgt)
70
+ return tgt
71
+
72
+ # TransformerEncoderRPR (only for music transformer)
73
+ class TransformerEncoderRPR(Module):
74
+ def __init__(self, encoder_layer, num_layers, norm=None):
75
+ super(TransformerEncoderRPR, self).__init__()
76
+ self.layers = _get_clones(encoder_layer, num_layers)
77
+ self.num_layers = num_layers
78
+ self.norm = norm
79
+ def forward(self, src, mask=None, src_key_padding_mask=None):
80
+ output = src
81
+ for i in range(self.num_layers):
82
+ output = self.layers[i](output, src_mask=mask,
83
+ src_key_padding_mask=src_key_padding_mask)
84
+ if self.norm:
85
+ output = self.norm(output)
86
+ return output
87
+
88
+ # TransformerEncoderLayerRPR (only for music transformer)
89
+ class TransformerEncoderLayerRPR(Module):
90
+ def __init__(self, d_model, nhead, dim_feedforward=2048, dropout=0.1, er_len=None):
91
+ super(TransformerEncoderLayerRPR, self).__init__()
92
+ self.self_attn = MultiheadAttentionRPR(d_model, nhead, dropout=dropout, er_len=er_len)
93
+ # Implementation of Feedforward model
94
+ self.linear1 = Linear(d_model, dim_feedforward)
95
+ self.dropout = Dropout(dropout)
96
+ self.linear2 = Linear(dim_feedforward, d_model)
97
+ self.norm1 = LayerNorm(d_model)
98
+ self.norm2 = LayerNorm(d_model)
99
+ self.dropout1 = Dropout(dropout)
100
+ self.dropout2 = Dropout(dropout)
101
+ def forward(self, src, src_mask=None, src_key_padding_mask=None):
102
+ src2 = self.self_attn(src, src, src, attn_mask=src_mask,
103
+ key_padding_mask=src_key_padding_mask)[0]
104
+ src = src + self.dropout1(src2)
105
+ src = self.norm1(src)
106
+ src2 = self.linear2(self.dropout(F.relu(self.linear1(src))))
107
+ src = src + self.dropout2(src2)
108
+ src = self.norm2(src)
109
+ return src
110
+
111
+ # MultiheadAttentionRPR
112
+ class MultiheadAttentionRPR(Module):
113
+ def __init__(self, embed_dim, num_heads, dropout=0., bias=True, add_bias_kv=False, add_zero_attn=False, kdim=None, vdim=None, er_len=None):
114
+ super(MultiheadAttentionRPR, self).__init__()
115
+ self.embed_dim = embed_dim
116
+ self.kdim = kdim if kdim is not None else embed_dim
117
+ self.vdim = vdim if vdim is not None else embed_dim
118
+ self._qkv_same_embed_dim = self.kdim == embed_dim and self.vdim == embed_dim
119
+
120
+ self.num_heads = num_heads
121
+ self.dropout = dropout
122
+ self.head_dim = embed_dim // num_heads
123
+ assert self.head_dim * num_heads == self.embed_dim, "embed_dim must be divisible by num_heads"
124
+
125
+ self.in_proj_weight = Parameter(torch.empty(3 * embed_dim, embed_dim))
126
+
127
+ if self._qkv_same_embed_dim is False:
128
+ self.q_proj_weight = Parameter(torch.Tensor(embed_dim, embed_dim))
129
+ self.k_proj_weight = Parameter(torch.Tensor(embed_dim, self.kdim))
130
+ self.v_proj_weight = Parameter(torch.Tensor(embed_dim, self.vdim))
131
+
132
+ if bias:
133
+ self.in_proj_bias = Parameter(torch.empty(3 * embed_dim))
134
+ else:
135
+ self.register_parameter('in_proj_bias', None)
136
+ self.out_proj = Linear(embed_dim, embed_dim, bias=bias)
137
+
138
+ if add_bias_kv:
139
+ self.bias_k = Parameter(torch.empty(1, 1, embed_dim))
140
+ self.bias_v = Parameter(torch.empty(1, 1, embed_dim))
141
+ else:
142
+ self.bias_k = self.bias_v = None
143
+
144
+ self.add_zero_attn = add_zero_attn
145
+
146
+ # Adding RPR embedding matrix
147
+ if(er_len is not None):
148
+ self.Er = Parameter(torch.rand((er_len, self.head_dim), dtype=torch.float32))
149
+ else:
150
+ self.Er = None
151
+
152
+ self._reset_parameters()
153
+
154
+ def _reset_parameters(self):
155
+ if self._qkv_same_embed_dim:
156
+ xavier_uniform_(self.in_proj_weight)
157
+ else:
158
+ xavier_uniform_(self.q_proj_weight)
159
+ xavier_uniform_(self.k_proj_weight)
160
+ xavier_uniform_(self.v_proj_weight)
161
+
162
+ if self.in_proj_bias is not None:
163
+ constant_(self.in_proj_bias, 0.)
164
+ constant_(self.out_proj.bias, 0.)
165
+ if self.bias_k is not None:
166
+ xavier_normal_(self.bias_k)
167
+ if self.bias_v is not None:
168
+ xavier_normal_(self.bias_v)
169
+
170
+ def forward(self, query, key, value, key_padding_mask=None,
171
+ need_weights=True, attn_mask=None):
172
+
173
+ if hasattr(self, '_qkv_same_embed_dim') and self._qkv_same_embed_dim is False:
174
+
175
+ return multi_head_attention_forward_rpr(
176
+ query, key, value, self.embed_dim, self.num_heads,
177
+ self.in_proj_weight, self.in_proj_bias,
178
+ self.bias_k, self.bias_v, self.add_zero_attn,
179
+ self.dropout, self.out_proj.weight, self.out_proj.bias,
180
+ training=self.training,
181
+ key_padding_mask=key_padding_mask, need_weights=need_weights,
182
+ attn_mask=attn_mask, use_separate_proj_weight=True,
183
+ q_proj_weight=self.q_proj_weight, k_proj_weight=self.k_proj_weight,
184
+ v_proj_weight=self.v_proj_weight, rpr_mat=self.Er)
185
+ else:
186
+ if not hasattr(self, '_qkv_same_embed_dim'):
187
+ warnings.warn('A new version of MultiheadAttention module has been implemented. \
188
+ Please re-train your model with the new module',
189
+ UserWarning)
190
+
191
+ return multi_head_attention_forward_rpr(
192
+ query, key, value, self.embed_dim, self.num_heads,
193
+ self.in_proj_weight, self.in_proj_bias,
194
+ self.bias_k, self.bias_v, self.add_zero_attn,
195
+ self.dropout, self.out_proj.weight, self.out_proj.bias,
196
+ training=self.training,
197
+ key_padding_mask=key_padding_mask, need_weights=need_weights,
198
+ attn_mask=attn_mask, rpr_mat=self.Er)
199
+
200
+ # multi_head_attention_forward_rpr
201
+ def multi_head_attention_forward_rpr(query, # type: Tensor
202
+ key, # type: Tensor
203
+ value, # type: Tensor
204
+ embed_dim_to_check, # type: int
205
+ num_heads, # type: int
206
+ in_proj_weight, # type: Tensor
207
+ in_proj_bias, # type: Tensor
208
+ bias_k, # type: Optional[Tensor]
209
+ bias_v, # type: Optional[Tensor]
210
+ add_zero_attn, # type: bool
211
+ dropout_p, # type: float
212
+ out_proj_weight, # type: Tensor
213
+ out_proj_bias, # type: Tensor
214
+ training=True, # type: bool
215
+ key_padding_mask=None, # type: Optional[Tensor]
216
+ need_weights=True, # type: bool
217
+ attn_mask=None, # type: Optional[Tensor]
218
+ use_separate_proj_weight=False, # type: bool
219
+ q_proj_weight=None, # type: Optional[Tensor]
220
+ k_proj_weight=None, # type: Optional[Tensor]
221
+ v_proj_weight=None, # type: Optional[Tensor]
222
+ static_k=None, # type: Optional[Tensor]
223
+ static_v=None, # type: Optional[Tensor]
224
+ rpr_mat=None
225
+ ):
226
+ """
227
+ ----------
228
+ Author: Pytorch
229
+ Modified: Damon Gwinn
230
+ ----------
231
+ For Relative Position Representation support (https://arxiv.org/abs/1803.02155)
232
+ https://pytorch.org/docs/1.2.0/_modules/torch/nn/functional.html
233
+ Modification to take RPR embedding matrix and perform skew optimized RPR (https://arxiv.org/abs/1809.04281)
234
+ ----------
235
+ """
236
+ # type: (...) -> Tuple[Tensor, Optional[Tensor]]
237
+
238
+ qkv_same = torch.equal(query, key) and torch.equal(key, value)
239
+ kv_same = torch.equal(key, value)
240
+
241
+ tgt_len, bsz, embed_dim = query.size()
242
+ assert embed_dim == embed_dim_to_check
243
+ assert list(query.size()) == [tgt_len, bsz, embed_dim]
244
+ assert key.size() == value.size()
245
+
246
+ head_dim = embed_dim // num_heads
247
+ assert head_dim * num_heads == embed_dim, "embed_dim must be divisible by num_heads"
248
+ scaling = float(head_dim) ** -0.5
249
+
250
+ if use_separate_proj_weight is not True:
251
+ if qkv_same:
252
+ # self-attention
253
+ q, k, v = linear(query, in_proj_weight, in_proj_bias).chunk(3, dim=-1)
254
+
255
+ elif kv_same:
256
+ # encoder-decoder attention
257
+ # This is inline in_proj function with in_proj_weight and in_proj_bias
258
+ _b = in_proj_bias
259
+ _start = 0
260
+ _end = embed_dim
261
+ _w = in_proj_weight[_start:_end, :]
262
+ if _b is not None:
263
+ _b = _b[_start:_end]
264
+ q = linear(query, _w, _b)
265
+
266
+ if key is None:
267
+ assert value is None
268
+ k = None
269
+ v = None
270
+ else:
271
+ # This is inline in_proj function with in_proj_weight and in_proj_bias
272
+ _b = in_proj_bias
273
+ _start = embed_dim
274
+ _end = None
275
+ _w = in_proj_weight[_start:, :]
276
+ if _b is not None:
277
+ _b = _b[_start:]
278
+ k, v = linear(key, _w, _b).chunk(2, dim=-1)
279
+
280
+ else:
281
+ # This is inline in_proj function with in_proj_weight and in_proj_bias
282
+ _b = in_proj_bias
283
+ _start = 0
284
+ _end = embed_dim
285
+ _w = in_proj_weight[_start:_end, :]
286
+ if _b is not None:
287
+ _b = _b[_start:_end]
288
+ q = linear(query, _w, _b)
289
+
290
+ # This is inline in_proj function with in_proj_weight and in_proj_bias
291
+ _b = in_proj_bias
292
+ _start = embed_dim
293
+ _end = embed_dim * 2
294
+ _w = in_proj_weight[_start:_end, :]
295
+ if _b is not None:
296
+ _b = _b[_start:_end]
297
+ k = linear(key, _w, _b)
298
+
299
+ # This is inline in_proj function with in_proj_weight and in_proj_bias
300
+ _b = in_proj_bias
301
+ _start = embed_dim * 2
302
+ _end = None
303
+ _w = in_proj_weight[_start:, :]
304
+ if _b is not None:
305
+ _b = _b[_start:]
306
+ v = linear(value, _w, _b)
307
+ else:
308
+ q_proj_weight_non_opt = torch.jit._unwrap_optional(q_proj_weight)
309
+ len1, len2 = q_proj_weight_non_opt.size()
310
+ assert len1 == embed_dim and len2 == query.size(-1)
311
+
312
+ k_proj_weight_non_opt = torch.jit._unwrap_optional(k_proj_weight)
313
+ len1, len2 = k_proj_weight_non_opt.size()
314
+ assert len1 == embed_dim and len2 == key.size(-1)
315
+
316
+ v_proj_weight_non_opt = torch.jit._unwrap_optional(v_proj_weight)
317
+ len1, len2 = v_proj_weight_non_opt.size()
318
+ assert len1 == embed_dim and len2 == value.size(-1)
319
+
320
+ if in_proj_bias is not None:
321
+ q = linear(query, q_proj_weight_non_opt, in_proj_bias[0:embed_dim])
322
+ k = linear(key, k_proj_weight_non_opt, in_proj_bias[embed_dim:(embed_dim * 2)])
323
+ v = linear(value, v_proj_weight_non_opt, in_proj_bias[(embed_dim * 2):])
324
+ else:
325
+ q = linear(query, q_proj_weight_non_opt, in_proj_bias)
326
+ k = linear(key, k_proj_weight_non_opt, in_proj_bias)
327
+ v = linear(value, v_proj_weight_non_opt, in_proj_bias)
328
+ q = q * scaling
329
+
330
+ if bias_k is not None and bias_v is not None:
331
+ if static_k is None and static_v is None:
332
+ k = torch.cat([k, bias_k.repeat(1, bsz, 1)])
333
+ v = torch.cat([v, bias_v.repeat(1, bsz, 1)])
334
+ if attn_mask is not None:
335
+ attn_mask = torch.cat([attn_mask,
336
+ torch.zeros((attn_mask.size(0), 1),
337
+ dtype=attn_mask.dtype,
338
+ device=attn_mask.device)], dim=1)
339
+ if key_padding_mask is not None:
340
+ key_padding_mask = torch.cat(
341
+ [key_padding_mask, torch.zeros((key_padding_mask.size(0), 1),
342
+ dtype=key_padding_mask.dtype,
343
+ device=key_padding_mask.device)], dim=1)
344
+ else:
345
+ assert static_k is None, "bias cannot be added to static key."
346
+ assert static_v is None, "bias cannot be added to static value."
347
+ else:
348
+ assert bias_k is None
349
+ assert bias_v is None
350
+
351
+ q = q.contiguous().view(tgt_len, bsz * num_heads, head_dim).transpose(0, 1)
352
+ if k is not None:
353
+ k = k.contiguous().view(-1, bsz * num_heads, head_dim).transpose(0, 1)
354
+ if v is not None:
355
+ v = v.contiguous().view(-1, bsz * num_heads, head_dim).transpose(0, 1)
356
+
357
+ if static_k is not None:
358
+ assert static_k.size(0) == bsz * num_heads
359
+ assert static_k.size(2) == head_dim
360
+ k = static_k
361
+
362
+ if static_v is not None:
363
+ assert static_v.size(0) == bsz * num_heads
364
+ assert static_v.size(2) == head_dim
365
+ v = static_v
366
+
367
+ src_len = k.size(1)
368
+
369
+ if key_padding_mask is not None:
370
+ assert key_padding_mask.size(0) == bsz
371
+ assert key_padding_mask.size(1) == src_len
372
+
373
+ if add_zero_attn:
374
+ src_len += 1
375
+ k = torch.cat([k, torch.zeros((k.size(0), 1) + k.size()[2:], dtype=k.dtype, device=k.device)], dim=1)
376
+ v = torch.cat([v, torch.zeros((v.size(0), 1) + v.size()[2:], dtype=v.dtype, device=v.device)], dim=1)
377
+ if attn_mask is not None:
378
+ attn_mask = torch.cat([attn_mask, torch.zeros((attn_mask.size(0), 1),
379
+ dtype=attn_mask.dtype,
380
+ device=attn_mask.device)], dim=1)
381
+ if key_padding_mask is not None:
382
+ key_padding_mask = torch.cat(
383
+ [key_padding_mask, torch.zeros((key_padding_mask.size(0), 1),
384
+ dtype=key_padding_mask.dtype,
385
+ device=key_padding_mask.device)], dim=1)
386
+
387
+ attn_output_weights = torch.bmm(q, k.transpose(1, 2))
388
+ assert list(attn_output_weights.size()) == [bsz * num_heads, tgt_len, src_len]
389
+
390
+ ######### ADDITION OF RPR ###########
391
+ if(rpr_mat is not None):
392
+ rpr_mat = _get_valid_embedding(rpr_mat, q.shape[1], k.shape[1])
393
+ qe = torch.einsum("hld,md->hlm", q, rpr_mat)
394
+ srel = _skew(qe)
395
+ attn_output_weights += srel
396
+
397
+ if attn_mask is not None:
398
+ attn_mask = attn_mask.unsqueeze(0)
399
+ attn_output_weights += attn_mask
400
+
401
+ if key_padding_mask is not None:
402
+ attn_output_weights = attn_output_weights.view(bsz, num_heads, tgt_len, src_len)
403
+ attn_output_weights = attn_output_weights.masked_fill(
404
+ key_padding_mask.unsqueeze(1).unsqueeze(2),
405
+ float('-inf'),
406
+ )
407
+ attn_output_weights = attn_output_weights.view(bsz * num_heads, tgt_len, src_len)
408
+
409
+ attn_output_weights = softmax(
410
+ attn_output_weights, dim=-1)
411
+
412
+ attn_output_weights = dropout(attn_output_weights, p=dropout_p, training=training)
413
+
414
+ attn_output = torch.bmm(attn_output_weights, v)
415
+ assert list(attn_output.size()) == [bsz * num_heads, tgt_len, head_dim]
416
+ attn_output = attn_output.transpose(0, 1).contiguous().view(tgt_len, bsz, embed_dim)
417
+ attn_output = linear(attn_output, out_proj_weight, out_proj_bias)
418
+
419
+ if need_weights:
420
+ # average attention weights over heads
421
+ attn_output_weights = attn_output_weights.view(bsz, num_heads, tgt_len, src_len)
422
+ return attn_output, attn_output_weights.sum(dim=1) / num_heads
423
+ else:
424
+ return attn_output, None
425
+
426
+ def _get_valid_embedding(Er, len_q, len_k):
427
+ """
428
+ ----------
429
+ Author: Damon Gwinn
430
+ ----------
431
+ Gets valid embeddings based on max length of RPR attention
432
+ ----------
433
+ """
434
+
435
+ len_e = Er.shape[0]
436
+ start = max(0, len_e - len_q)
437
+ return Er[start:, :]
438
+
439
+ def _skew(qe):
440
+ """
441
+ ----------
442
+ Author: Damon Gwinn
443
+ ----------
444
+ Performs the skew optimized RPR computation (https://arxiv.org/abs/1809.04281)
445
+ ----------
446
+ """
447
+ sz = qe.shape[1]
448
+ mask = (torch.triu(torch.ones(sz, sz).to(qe.device)) == 1).float().flip(0)
449
+
450
+ qe = mask * qe
451
+ qe = F.pad(qe, (1,0, 0,0, 0,0))
452
+ qe = torch.reshape(qe, (qe.shape[0], qe.shape[2], qe.shape[1]))
453
+
454
+ srel = qe[:, 1:, :]
455
+ return srel
model/video_music_transformer.py ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ from torch.nn.modules.normalization import LayerNorm
4
+ import random
5
+ import numpy as np
6
+ from utilities.constants import *
7
+ from utilities.device import get_device
8
+ from .positional_encoding import PositionalEncoding
9
+ from .rpr import TransformerDecoderRPR, TransformerDecoderLayerRPR
10
+ from datetime import datetime
11
+ import json
12
+
13
+
14
+ class VideoMusicTransformer(nn.Module):
15
+ def __init__(self, n_layers=6, num_heads=8, d_model=512, dim_feedforward=1024,
16
+ dropout=0.1, max_sequence_midi =2048, max_sequence_video=300, max_sequence_chord=300, total_vf_dim = 0, rpr=False):
17
+ super(VideoMusicTransformer, self).__init__()
18
+ self.nlayers = n_layers
19
+ self.nhead = num_heads
20
+ self.d_model = d_model
21
+ self.d_ff = dim_feedforward
22
+ self.dropout = dropout
23
+ self.max_seq_midi = max_sequence_midi
24
+ self.max_seq_video = max_sequence_video
25
+ self.max_seq_chord = max_sequence_chord
26
+ self.rpr = rpr
27
+
28
+ # Input embedding for video and music features
29
+ self.embedding = nn.Embedding(CHORD_SIZE, self.d_model)
30
+ self.embedding_root = nn.Embedding(CHORD_ROOT_SIZE, self.d_model)
31
+ self.embedding_attr = nn.Embedding(CHORD_ATTR_SIZE, self.d_model)
32
+
33
+ self.total_vf_dim = total_vf_dim
34
+ self.Linear_vis = nn.Linear(self.total_vf_dim, self.d_model)
35
+ self.Linear_chord = nn.Linear(self.d_model+1, self.d_model)
36
+
37
+ # Positional encoding
38
+ self.positional_encoding = PositionalEncoding(self.d_model, self.dropout, self.max_seq_chord)
39
+ self.positional_encoding_video = PositionalEncoding(self.d_model, self.dropout, self.max_seq_video)
40
+
41
+ # Add condition (minor or major)
42
+ self.condition_linear = nn.Linear(1, self.d_model)
43
+
44
+ # Base transformer
45
+ if(not self.rpr):
46
+ self.transformer = nn.Transformer(
47
+ d_model=self.d_model, nhead=self.nhead, num_encoder_layers=self.nlayers,
48
+ num_decoder_layers=self.nlayers, dropout=self.dropout, # activation=self.ff_activ,
49
+ dim_feedforward=self.d_ff
50
+ )
51
+ # RPR Transformer
52
+ else:
53
+ decoder_norm = LayerNorm(self.d_model)
54
+ decoder_layer = TransformerDecoderLayerRPR(self.d_model, self.nhead, self.d_ff, self.dropout, er_len=self.max_seq_chord)
55
+ decoder = TransformerDecoderRPR(decoder_layer, self.nlayers, decoder_norm)
56
+ self.transformer = nn.Transformer(
57
+ d_model=self.d_model, nhead=self.nhead, num_encoder_layers=self.nlayers,
58
+ num_decoder_layers=self.nlayers, dropout=self.dropout, # activation=self.ff_activ,
59
+ dim_feedforward=self.d_ff, custom_decoder=decoder
60
+ )
61
+
62
+ self.Wout = nn.Linear(self.d_model, CHORD_SIZE)
63
+ self.Wout_root = nn.Linear(self.d_model, CHORD_ROOT_SIZE)
64
+ self.Wout_attr = nn.Linear(self.d_model, CHORD_ATTR_SIZE)
65
+ self.softmax = nn.Softmax(dim=-1)
66
+ self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
67
+
68
+ def forward(self, x, x_root, x_attr, feature_semantic_list, feature_key, feature_scene_offset, feature_motion, feature_emotion, mask=True):
69
+ if(mask is True):
70
+ mask = self.transformer.generate_square_subsequent_mask(x.shape[1]).to(self.device)
71
+ else:
72
+ mask = None
73
+
74
+ x_root = self.embedding_root(x_root)
75
+ x_attr = self.embedding_attr(x_attr)
76
+ x = x_root + x_attr
77
+
78
+ feature_key_padded = torch.full((x.shape[0], x.shape[1], 1), feature_key.item())
79
+ feature_key_padded = feature_key_padded.to(self.device)
80
+ x = torch.cat([x, feature_key_padded], dim=-1)
81
+
82
+ xf = self.Linear_chord(x)
83
+
84
+ ### Video (SemanticList + SceneOffset + Motion + Emotion) (ENCODER) ###
85
+ vf_concat = feature_semantic_list[0].float()
86
+
87
+ for i in range(1, len(feature_semantic_list)):
88
+ vf_concat = torch.cat( (vf_concat, feature_semantic_list[i].float()), dim=2)
89
+
90
+ vf_concat = torch.cat([vf_concat, feature_scene_offset.unsqueeze(-1).float()], dim=-1) # -> (max_seq_video, batch_size, d_model+1)
91
+ vf_concat = torch.cat([vf_concat, feature_motion.unsqueeze(-1).float()], dim=-1) # -> (max_seq_video, batch_size, d_model+1)
92
+ vf_concat = torch.cat([vf_concat, feature_emotion.float()], dim=-1) # -> (max_seq_video, batch_size, d_model+1)
93
+ vf = self.Linear_vis(vf_concat)
94
+
95
+ ### POSITIONAL ENCODING ###
96
+
97
+ xf = xf.permute(1,0,2) # -> (max_seq-1, batch_size, d_model)
98
+ vf = vf.permute(1,0,2) # -> (max_seq_video, batch_size, d_model)
99
+
100
+ xf = self.positional_encoding(xf)
101
+ vf = self.positional_encoding_video(vf)
102
+
103
+ ### TRANSFORMER ###
104
+ x_out = self.transformer(src=vf, tgt=xf, tgt_mask=mask)
105
+ x_out = x_out.permute(1,0,2)
106
+
107
+ if IS_SEPERATED:
108
+ y_root = self.Wout_root(x_out)
109
+ y_attr = self.Wout_attr(x_out)
110
+ del mask
111
+ return y_root, y_attr
112
+ else:
113
+ y = self.Wout(x_out)
114
+ del mask
115
+ return y
116
+
117
+ def generate(self, feature_semantic_list = [], feature_key=None, feature_scene_offset=None, feature_motion=None, feature_emotion=None,
118
+ primer=None, primer_root=None, primer_attr=None, target_seq_length=300, beam=0,
119
+ beam_chance=1.0, max_conseq_N = 0, max_conseq_chord = 2):
120
+
121
+ assert (not self.training), "Cannot generate while in training mode"
122
+ print("Generating sequence of max length:", target_seq_length)
123
+
124
+ with open('dataset/vevo_meta/chord_inv.json') as json_file:
125
+ chordInvDic = json.load(json_file)
126
+ with open('dataset/vevo_meta/chord_root.json') as json_file:
127
+ chordRootDic = json.load(json_file)
128
+ with open('dataset/vevo_meta/chord_attr.json') as json_file:
129
+ chordAttrDic = json.load(json_file)
130
+
131
+ gen_seq = torch.full((1,target_seq_length), CHORD_PAD, dtype=TORCH_LABEL_TYPE, device=self.device)
132
+ gen_seq_root = torch.full((1,target_seq_length), CHORD_ROOT_PAD, dtype=TORCH_LABEL_TYPE, device=self.device)
133
+ gen_seq_attr = torch.full((1,target_seq_length), CHORD_ATTR_PAD, dtype=TORCH_LABEL_TYPE, device=self.device)
134
+
135
+ num_primer = len(primer)
136
+ gen_seq[..., :num_primer] = primer.type(TORCH_LABEL_TYPE).to(self.device)
137
+ gen_seq_root[..., :num_primer] = primer_root.type(TORCH_LABEL_TYPE).to(self.device)
138
+ gen_seq_attr[..., :num_primer] = primer_attr.type(TORCH_LABEL_TYPE).to(self.device)
139
+
140
+ cur_i = num_primer
141
+ while(cur_i < target_seq_length):
142
+ y = self.softmax( self.forward( gen_seq[..., :cur_i], gen_seq_root[..., :cur_i], gen_seq_attr[..., :cur_i],
143
+ feature_semantic_list, feature_key, feature_scene_offset, feature_motion, feature_emotion) )[..., :CHORD_END]
144
+
145
+ token_probs = y[:, cur_i-1, :]
146
+ if(beam == 0):
147
+ beam_ran = 2.0
148
+ else:
149
+ beam_ran = random.uniform(0,1)
150
+ if(beam_ran <= beam_chance):
151
+ token_probs = token_probs.flatten()
152
+ top_res, top_i = torch.topk(token_probs, beam)
153
+ beam_rows = top_i // CHORD_SIZE
154
+ beam_cols = top_i % CHORD_SIZE
155
+ gen_seq = gen_seq[beam_rows, :]
156
+ gen_seq[..., cur_i] = beam_cols
157
+ else:
158
+ # token_probs.shape : [1, 157]
159
+ # 0: N, 1: C, ... , 156: B:maj7
160
+ # 157 chordEnd 158 padding
161
+ if max_conseq_N == 0:
162
+ token_probs[0][0] = 0.0
163
+ isMaxChord = True
164
+ if cur_i >= max_conseq_chord :
165
+ preChord = gen_seq[0][cur_i-1].item()
166
+ for k in range (1, max_conseq_chord):
167
+ if preChord != gen_seq[0][cur_i-1-k].item():
168
+ isMaxChord = False
169
+ else:
170
+ isMaxChord = False
171
+
172
+ if isMaxChord:
173
+ preChord = gen_seq[0][cur_i-1].item()
174
+ token_probs[0][preChord] = 0.0
175
+
176
+ distrib = torch.distributions.categorical.Categorical(probs=token_probs)
177
+ next_token = distrib.sample()
178
+ gen_seq[:, cur_i] = next_token
179
+ gen_chord = chordInvDic[ str( next_token.item() ) ]
180
+
181
+ chord_arr = gen_chord.split(":")
182
+ if len(chord_arr) == 1:
183
+ chordRootID = chordRootDic[chord_arr[0]]
184
+ chordAttrID = 1
185
+ chordRootID = torch.tensor([chordRootID]).to(self.device)
186
+ chordAttrID = torch.tensor([chordAttrID]).to(self.device)
187
+ gen_seq_root[:, cur_i] = chordRootID
188
+ gen_seq_attr[:, cur_i] = chordAttrID
189
+ elif len(chord_arr) == 2:
190
+ chordRootID = chordRootDic[chord_arr[0]]
191
+ chordAttrID = chordAttrDic[chord_arr[1]]
192
+ chordRootID = torch.tensor([chordRootID]).to(self.device)
193
+ chordAttrID = torch.tensor([chordAttrID]).to(self.device)
194
+ gen_seq_root[:, cur_i] = chordRootID
195
+ gen_seq_attr[:, cur_i] = chordAttrID
196
+
197
+ # Let the transformer decide to end if it wants to
198
+ if(next_token == CHORD_END):
199
+ print("Model called end of sequence at:", cur_i, "/", target_seq_length)
200
+ break
201
+ cur_i += 1
202
+ if(cur_i % 50 == 0):
203
+ print(cur_i, "/", target_seq_length)
204
+ return gen_seq[:, :cur_i]
205
+
model/video_regression.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ from torch.nn.modules.normalization import LayerNorm
4
+ import random
5
+ import numpy as np
6
+ from utilities.constants import *
7
+ from utilities.device import get_device
8
+ from datetime import datetime
9
+
10
+ import torch.nn.functional as F
11
+
12
+ class VideoRegression(nn.Module):
13
+ def __init__(self, n_layers=2, d_model=64, dropout=0.1, max_sequence_video=300, total_vf_dim = 0, regModel="bilstm"):
14
+ super(VideoRegression, self).__init__()
15
+ self.nlayers = n_layers
16
+ self.d_model = d_model
17
+ self.dropout = dropout
18
+ self.max_seq_video = max_sequence_video
19
+ self.total_vf_dim = total_vf_dim
20
+ self.regModel = regModel
21
+
22
+ self.bilstm = nn.LSTM(self.total_vf_dim, self.d_model, self.nlayers, bidirectional=True)
23
+ self.bigru = nn.GRU(self.total_vf_dim, self.d_model, self.nlayers, bidirectional=True)
24
+ self.bifc = nn.Linear(self.d_model * 2, 2)
25
+
26
+ self.lstm = nn.LSTM(self.total_vf_dim, self.d_model, self.nlayers)
27
+ self.gru = nn.GRU(self.total_vf_dim, self.d_model, self.nlayers)
28
+ self.fc = nn.Linear(self.d_model, 2)
29
+
30
+ self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
31
+
32
+
33
+
34
+ def forward(self, feature_semantic_list, feature_scene_offset, feature_motion, feature_emotion):
35
+ ### Video (SemanticList + SceneOffset + Motion + Emotion) (ENCODER) ###
36
+ vf_concat = feature_semantic_list[0].float()
37
+ for i in range(1, len(feature_semantic_list)):
38
+ vf_concat = torch.cat( (vf_concat, feature_semantic_list[i].float()), dim=2)
39
+
40
+ vf_concat = torch.cat([vf_concat, feature_scene_offset.unsqueeze(-1).float()], dim=-1)
41
+ vf_concat = torch.cat([vf_concat, feature_motion.unsqueeze(-1).float()], dim=-1)
42
+ vf_concat = torch.cat([vf_concat, feature_emotion.float()], dim=-1)
43
+
44
+ vf_concat = vf_concat.permute(1,0,2)
45
+ vf_concat = F.dropout(vf_concat, p=self.dropout, training=self.training)
46
+
47
+ if self.regModel == "bilstm":
48
+ out, _ = self.bilstm(vf_concat)
49
+ out = out.permute(1,0,2)
50
+ out = self.bifc(out)
51
+ elif self.regModel == "bigru":
52
+ out, _ = self.bigru(vf_concat)
53
+ out = out.permute(1,0,2)
54
+ out = self.bifc(out)
55
+ elif self.regModel == "lstm":
56
+ out, _ = self.lstm(vf_concat)
57
+ out = out.permute(1,0,2)
58
+ out = self.fc(out)
59
+ elif self.regModel == "gru":
60
+ out, _ = self.gru(vf_concat)
61
+ out = out.permute(1,0,2)
62
+ out = self.fc(out)
63
+ return out
64
+
packages.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ffmpeg
2
+ fluidsynth
requirements.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torchvision==0.9.0
2
+ torch==1.8.0
3
+ clip @ git+https://github.com/openai/CLIP.git
4
+ Cython==3.0.5
5
+ numpy==1.19.5
6
+ coloredlogs==15.0.1
7
+ ffmpeg_python==0.2.0
8
+ ftfy==6.1.1
9
+ matplotlib==3.5.3
10
+ midi2audio==0.1.1
11
+ MIDIUtil==1.2.1
12
+ moviepy==1.0.3
13
+ music21==7.3.3
14
+ opencv_python==4.7.0.72
15
+ pandas==1.3.5
16
+ Pillow==8.4.0
17
+ pretty_midi==0.2.9
18
+ pydub==0.25.1
19
+ regex==2022.10.31
20
+ scenedetect==0.6.1
21
+ scikit_learn==1.0.2
22
+ scipy==1.7.3
23
+ gradio==4.7.1
24
+ pyfluidsynth
saved_models/AMT/README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ put pickle files in this directory
saved_models/AMT/best_loss_weights.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:859f0fac92c6d4ac84446983cd138ca8d625a41e1854edbd86ea29a14f0aad28
3
+ size 131375779
saved_models/AMT/best_rmse_weights.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3680851df4f8bb7902539bc10b3025eaa7162410826c164b4aec4d44a8c19818
3
+ size 5463439
third_party/midi_processor/__pycache__/processor.cpython-37.pyc ADDED
Binary file (7.38 kB). View file
 
third_party/midi_processor/__pycache__/processor.cpython-38.pyc ADDED
Binary file (7.46 kB). View file
 
third_party/midi_processor/processor.py ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pretty_midi
2
+
3
+ RANGE_NOTE_ON = 128
4
+ RANGE_NOTE_OFF = 128
5
+ RANGE_VEL = 32
6
+ RANGE_TIME_SHIFT = 100
7
+
8
+ START_IDX = {
9
+ 'note_on': 0,
10
+ 'note_off': RANGE_NOTE_ON,
11
+ 'time_shift': RANGE_NOTE_ON + RANGE_NOTE_OFF,
12
+ 'velocity': RANGE_NOTE_ON + RANGE_NOTE_OFF + RANGE_TIME_SHIFT
13
+ }
14
+
15
+ class SustainAdapter:
16
+ def __init__(self, time, type):
17
+ self.start = time
18
+ self.type = type
19
+
20
+
21
+ class SustainDownManager:
22
+ def __init__(self, start, end):
23
+ self.start = start
24
+ self.end = end
25
+ self.managed_notes = []
26
+ self._note_dict = {} # key: pitch, value: note.start
27
+
28
+ def add_managed_note(self, note: pretty_midi.Note):
29
+ self.managed_notes.append(note)
30
+
31
+ def transposition_notes(self):
32
+ for note in reversed(self.managed_notes):
33
+ try:
34
+ note.end = self._note_dict[note.pitch]
35
+ except KeyError:
36
+ note.end = max(self.end, note.end)
37
+ self._note_dict[note.pitch] = note.start
38
+
39
+
40
+ # Divided note by note_on, note_off
41
+ class SplitNote:
42
+ def __init__(self, type, time, value, velocity):
43
+ ## type: note_on, note_off
44
+ self.type = type
45
+ self.time = time
46
+ self.velocity = velocity
47
+ self.value = value
48
+
49
+ def __repr__(self):
50
+ return '<[SNote] time: {} type: {}, value: {}, velocity: {}>'\
51
+ .format(self.time, self.type, self.value, self.velocity)
52
+
53
+
54
+ class Event:
55
+ def __init__(self, event_type, value):
56
+ self.type = event_type
57
+ self.value = value
58
+
59
+ def __repr__(self):
60
+ return '<Event type: {}, value: {}>'.format(self.type, self.value)
61
+
62
+ def to_int(self):
63
+ return START_IDX[self.type] + self.value
64
+
65
+ @staticmethod
66
+ def from_int(int_value):
67
+ info = Event._type_check(int_value)
68
+ return Event(info['type'], info['value'])
69
+
70
+ @staticmethod
71
+ def _type_check(int_value):
72
+ range_note_on = range(0, RANGE_NOTE_ON)
73
+ range_note_off = range(RANGE_NOTE_ON, RANGE_NOTE_ON+RANGE_NOTE_OFF)
74
+ range_time_shift = range(RANGE_NOTE_ON+RANGE_NOTE_OFF,RANGE_NOTE_ON+RANGE_NOTE_OFF+RANGE_TIME_SHIFT)
75
+
76
+ valid_value = int_value
77
+
78
+ if int_value in range_note_on:
79
+ return {'type': 'note_on', 'value': valid_value}
80
+ elif int_value in range_note_off:
81
+ valid_value -= RANGE_NOTE_ON
82
+ return {'type': 'note_off', 'value': valid_value}
83
+ elif int_value in range_time_shift:
84
+ valid_value -= (RANGE_NOTE_ON + RANGE_NOTE_OFF)
85
+ return {'type': 'time_shift', 'value': valid_value}
86
+ else:
87
+ valid_value -= (RANGE_NOTE_ON + RANGE_NOTE_OFF + RANGE_TIME_SHIFT)
88
+ return {'type': 'velocity', 'value': valid_value}
89
+
90
+
91
+ def _divide_note(notes):
92
+ result_array = []
93
+ notes.sort(key=lambda x: x.start)
94
+
95
+ for note in notes:
96
+ on = SplitNote('note_on', note.start, note.pitch, note.velocity)
97
+ off = SplitNote('note_off', note.end, note.pitch, None)
98
+ result_array += [on, off]
99
+ return result_array
100
+
101
+
102
+ def _merge_note(snote_sequence):
103
+ note_on_dict = {}
104
+ result_array = []
105
+
106
+ for snote in snote_sequence:
107
+ # print(note_on_dict)
108
+ if snote.type == 'note_on':
109
+ note_on_dict[snote.value] = snote
110
+ elif snote.type == 'note_off':
111
+ try:
112
+ on = note_on_dict[snote.value]
113
+ off = snote
114
+ if off.time - on.time == 0:
115
+ continue
116
+ result = pretty_midi.Note(on.velocity, snote.value, on.time, off.time)
117
+ result_array.append(result)
118
+ except:
119
+ print('info removed pitch: {}'.format(snote.value))
120
+ return result_array
121
+
122
+
123
+ def _snote2events(snote: SplitNote, prev_vel: int):
124
+ result = []
125
+ if snote.velocity is not None:
126
+ modified_velocity = snote.velocity // 4
127
+ if prev_vel != modified_velocity:
128
+ result.append(Event(event_type='velocity', value=modified_velocity))
129
+ result.append(Event(event_type=snote.type, value=snote.value))
130
+ return result
131
+
132
+
133
+ def _event_seq2snote_seq(event_sequence):
134
+ timeline = 0
135
+ velocity = 0
136
+ snote_seq = []
137
+
138
+ for event in event_sequence:
139
+ if event.type == 'time_shift':
140
+ timeline += ((event.value+1) / 100)
141
+ if event.type == 'velocity':
142
+ velocity = event.value * 4
143
+ else:
144
+ snote = SplitNote(event.type, timeline, event.value, velocity)
145
+ snote_seq.append(snote)
146
+ return snote_seq
147
+
148
+
149
+ def _make_time_sift_events(prev_time, post_time):
150
+ time_interval = int(round((post_time - prev_time) * 100))
151
+ results = []
152
+ while time_interval >= RANGE_TIME_SHIFT:
153
+ results.append(Event(event_type='time_shift', value=RANGE_TIME_SHIFT-1))
154
+ time_interval -= RANGE_TIME_SHIFT
155
+ if time_interval == 0:
156
+ return results
157
+ else:
158
+ return results + [Event(event_type='time_shift', value=time_interval-1)]
159
+
160
+
161
+ def _control_preprocess(ctrl_changes):
162
+ sustains = []
163
+
164
+ manager = None
165
+ for ctrl in ctrl_changes:
166
+ if ctrl.value >= 64 and manager is None:
167
+ # sustain down
168
+ manager = SustainDownManager(start=ctrl.time, end=None)
169
+ elif ctrl.value < 64 and manager is not None:
170
+ # sustain up
171
+ manager.end = ctrl.time
172
+ sustains.append(manager)
173
+ manager = None
174
+ elif ctrl.value < 64 and len(sustains) > 0:
175
+ sustains[-1].end = ctrl.time
176
+ return sustains
177
+
178
+
179
+ def _note_preprocess(susteins, notes):
180
+ note_stream = []
181
+
182
+ if susteins: # if the midi file has sustain controls
183
+ for sustain in susteins:
184
+ for note_idx, note in enumerate(notes):
185
+ if note.start < sustain.start:
186
+ note_stream.append(note)
187
+ elif note.start > sustain.end:
188
+ notes = notes[note_idx:]
189
+ sustain.transposition_notes()
190
+ break
191
+ else:
192
+ sustain.add_managed_note(note)
193
+
194
+ for sustain in susteins:
195
+ note_stream += sustain.managed_notes
196
+
197
+ else: # else, just push everything into note stream
198
+ for note_idx, note in enumerate(notes):
199
+ note_stream.append(note)
200
+
201
+ note_stream.sort(key= lambda x: x.start)
202
+ return note_stream
203
+
204
+
205
+ def encode_midi(file_path):
206
+ events = []
207
+ notes = []
208
+ mid = pretty_midi.PrettyMIDI(midi_file=file_path)
209
+
210
+ for inst in mid.instruments:
211
+ inst_notes = inst.notes
212
+ # ctrl.number is the number of sustain control. If you want to know abour the number type of control,
213
+ # see https://www.midi.org/specifications-old/item/table-3-control-change-messages-data-bytes-2
214
+ ctrls = _control_preprocess([ctrl for ctrl in inst.control_changes if ctrl.number == 64])
215
+ notes += _note_preprocess(ctrls, inst_notes)
216
+
217
+ dnotes = _divide_note(notes)
218
+ # print(dnotes)
219
+ dnotes.sort(key=lambda x: x.time)
220
+ # print('sorted:')
221
+ # print(dnotes)
222
+ cur_time = 0
223
+ cur_vel = 0
224
+ for snote in dnotes:
225
+ events += _make_time_sift_events(prev_time=cur_time, post_time=snote.time)
226
+ events += _snote2events(snote=snote, prev_vel=cur_vel)
227
+ # events += _make_time_sift_events(prev_time=cur_time, post_time=snote.time)
228
+ cur_time = snote.time
229
+ cur_vel = snote.velocity
230
+
231
+ return [e.to_int() for e in events]
232
+
233
+ def decode_midi(idx_array, file_path=None):
234
+ event_sequence = [Event.from_int(idx) for idx in idx_array]
235
+ # print(event_sequence)
236
+ snote_seq = _event_seq2snote_seq(event_sequence)
237
+ note_seq = _merge_note(snote_seq)
238
+ note_seq.sort(key=lambda x:x.start)
239
+
240
+ mid = pretty_midi.PrettyMIDI()
241
+ # if want to change instument, see https://www.midi.org/specifications/item/gm-level-1-sound-set
242
+ instument = pretty_midi.Instrument(1, False, "Developed By Jaeyong Kang")
243
+ instument.notes = note_seq
244
+
245
+ mid.instruments.append(instument)
246
+ if file_path is not None:
247
+ mid.write(file_path)
248
+ return mid
249
+
250
+ # if __name__ == '__main__':
251
+ # encoded = encode_midi('bin/ADIG04.mid')
252
+ # print(encoded)
253
+ # decided = decode_midi(encoded,file_path='bin/test.mid')
254
+
255
+ # ins = pretty_midi.PrettyMIDI('bin/ADIG04.mid')
256
+ # print(ins)
257
+ # print(ins.instruments[0])
258
+ # for i in ins.instruments:
259
+ # print(i.control_changes)
260
+ # print(i.notes)
261
+
utilities/__init__.py ADDED
File without changes
utilities/__pycache__/__init__.cpython-37.pyc ADDED
Binary file (139 Bytes). View file
 
utilities/__pycache__/__init__.cpython-38.pyc ADDED
Binary file (143 Bytes). View file
 
utilities/__pycache__/argument_funcs.cpython-37.pyc ADDED
Binary file (10.4 kB). View file
 
utilities/__pycache__/chord_to_midi.cpython-37.pyc ADDED
Binary file (5.37 kB). View file
 
utilities/__pycache__/chord_to_midi.cpython-38.pyc ADDED
Binary file (5.39 kB). View file
 
utilities/__pycache__/constants.cpython-37.pyc ADDED
Binary file (1.53 kB). View file
 
utilities/__pycache__/constants.cpython-38.pyc ADDED
Binary file (1.54 kB). View file
 
utilities/__pycache__/device.cpython-37.pyc ADDED
Binary file (1.45 kB). View file
 
utilities/__pycache__/device.cpython-38.pyc ADDED
Binary file (1.47 kB). View file
 
utilities/argument_funcs.py ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ from .constants import *
3
+
4
+ version = VERSION
5
+ split_ver = SPLIT_VER
6
+ split_path = "split_" + split_ver
7
+
8
+ def parse_train_args():
9
+ parser = argparse.ArgumentParser()
10
+
11
+ parser.add_argument("-dataset_dir", type=str, default="./dataset/", help="Folder of VEVO dataset")
12
+
13
+ parser.add_argument("-input_dir_music", type=str, default="./dataset/vevo_chord/" + MUSIC_TYPE, help="Folder of video CNN feature files")
14
+ parser.add_argument("-input_dir_video", type=str, default="./dataset/vevo_vis", help="Folder of video CNN feature files")
15
+
16
+ parser.add_argument("-output_dir", type=str, default="./saved_models", help="Folder to save model weights. Saves one every epoch")
17
+
18
+ parser.add_argument("-weight_modulus", type=int, default=1, help="How often to save epoch weights (ex: value of 10 means save every 10 epochs)")
19
+ parser.add_argument("-print_modulus", type=int, default=1, help="How often to print train results for a batch (batch loss, learn rate, etc.)")
20
+ parser.add_argument("-n_workers", type=int, default=1, help="Number of threads for the dataloader")
21
+ parser.add_argument("--force_cpu", action="store_true", help="Forces model to run on a cpu even when gpu is available")
22
+ parser.add_argument("--no_tensorboard", action="store_true", help="Turns off tensorboard result reporting")
23
+ parser.add_argument("-continue_weights", type=str, default=None, help="Model weights to continue training based on")
24
+ parser.add_argument("-continue_epoch", type=int, default=None, help="Epoch the continue_weights model was at")
25
+ parser.add_argument("-lr", type=float, default=None, help="Constant learn rate. Leave as None for a custom scheduler.")
26
+ parser.add_argument("-ce_smoothing", type=float, default=None, help="Smoothing parameter for smoothed cross entropy loss (defaults to no smoothing)")
27
+ parser.add_argument("-batch_size", type=int, default=1, help="Batch size to use")
28
+ parser.add_argument("-epochs", type=int, default=5, help="Number of epochs to use")
29
+
30
+ parser.add_argument("-max_sequence_midi", type=int, default=2048, help="Maximum midi sequence to consider")
31
+ parser.add_argument("-max_sequence_video", type=int, default=300, help="Maximum video sequence to consider")
32
+ parser.add_argument("-max_sequence_chord", type=int, default=300, help="Maximum video sequence to consider")
33
+
34
+ parser.add_argument("-n_layers", type=int, default=6, help="Number of decoder layers to use")
35
+ parser.add_argument("-num_heads", type=int, default=8, help="Number of heads to use for multi-head attention")
36
+ parser.add_argument("-d_model", type=int, default=512, help="Dimension of the model (output dim of embedding layers, etc.)")
37
+ parser.add_argument("-dim_feedforward", type=int, default=1024, help="Dimension of the feedforward layer")
38
+ parser.add_argument("-dropout", type=float, default=0.1, help="Dropout rate")
39
+
40
+ parser.add_argument("-is_video", type=bool, default=IS_VIDEO, help="MusicTransformer or VideoMusicTransformer")
41
+
42
+ if IS_VIDEO:
43
+ parser.add_argument("-vis_models", type=str, default=VIS_MODELS_SORTED, help="...")
44
+ else:
45
+ parser.add_argument("-vis_models", type=str, default="", help="...")
46
+
47
+ parser.add_argument("-emo_model", type=str, default="6c_l14p", help="...")
48
+ parser.add_argument("-rpr", type=bool, default=RPR, help="...")
49
+ return parser.parse_args()
50
+
51
+ def print_train_args(args):
52
+ print(SEPERATOR)
53
+
54
+ print("dataset_dir:", args.dataset_dir )
55
+
56
+ print("input_dir_music:", args.input_dir_music)
57
+ print("input_dir_video:", args.input_dir_video)
58
+
59
+ print("output_dir:", args.output_dir)
60
+
61
+ print("weight_modulus:", args.weight_modulus)
62
+ print("print_modulus:", args.print_modulus)
63
+ print("")
64
+ print("n_workers:", args.n_workers)
65
+ print("force_cpu:", args.force_cpu)
66
+ print("tensorboard:", not args.no_tensorboard)
67
+ print("")
68
+ print("continue_weights:", args.continue_weights)
69
+ print("continue_epoch:", args.continue_epoch)
70
+ print("")
71
+ print("lr:", args.lr)
72
+ print("ce_smoothing:", args.ce_smoothing)
73
+ print("batch_size:", args.batch_size)
74
+ print("epochs:", args.epochs)
75
+ print("")
76
+ print("rpr:", args.rpr)
77
+
78
+ print("max_sequence_midi:", args.max_sequence_midi)
79
+ print("max_sequence_video:", args.max_sequence_video)
80
+ print("max_sequence_chord:", args.max_sequence_chord)
81
+
82
+ print("n_layers:", args.n_layers)
83
+ print("num_heads:", args.num_heads)
84
+ print("d_model:", args.d_model)
85
+ print("")
86
+ print("dim_feedforward:", args.dim_feedforward)
87
+ print("dropout:", args.dropout)
88
+ print("is_video:", args.is_video)
89
+
90
+ print(SEPERATOR)
91
+ print("")
92
+
93
+ def parse_eval_args():
94
+ if IS_VIDEO:
95
+ modelpath = "./saved_models/AMT/best_acc_weights.pickle"
96
+ # modelpath = "./saved_models/"+version+ "/"+VIS_MODELS_PATH+"/results/best_loss_weights.pickle"
97
+ else:
98
+ modelpath = "./saved_models/"+version+ "/no_video/results/best_acc_weights.pickle"
99
+
100
+ parser = argparse.ArgumentParser()
101
+
102
+ parser.add_argument("-dataset_dir", type=str, default="./dataset/", help="Folder of VEVO dataset")
103
+
104
+ parser.add_argument("-input_dir_music", type=str, default="./dataset/vevo_chord/" + MUSIC_TYPE, help="Folder of video CNN feature files")
105
+ parser.add_argument("-input_dir_video", type=str, default="./dataset/vevo_vis", help="Folder of video CNN feature files")
106
+
107
+ parser.add_argument("-model_weights", type=str, default= modelpath, help="Pickled model weights file saved with torch.save and model.state_dict()")
108
+
109
+ parser.add_argument("-n_workers", type=int, default=1, help="Number of threads for the dataloader")
110
+ parser.add_argument("--force_cpu", action="store_true", help="Forces model to run on a cpu even when gpu is available")
111
+ parser.add_argument("-batch_size", type=int, default=1, help="Batch size to use")
112
+
113
+ parser.add_argument("-max_sequence_midi", type=int, default=2048, help="Maximum midi sequence to consider")
114
+ parser.add_argument("-max_sequence_video", type=int, default=300, help="Maximum video sequence to consider")
115
+ parser.add_argument("-max_sequence_chord", type=int, default=300, help="Maximum video sequence to consider")
116
+
117
+ parser.add_argument("-n_layers", type=int, default=6, help="Number of decoder layers to use")
118
+ parser.add_argument("-num_heads", type=int, default=8, help="Number of heads to use for multi-head attention")
119
+ parser.add_argument("-d_model", type=int, default=512, help="Dimension of the model (output dim of embedding layers, etc.)")
120
+ parser.add_argument("-dim_feedforward", type=int, default=1024, help="Dimension of the feedforward layer")
121
+
122
+ parser.add_argument("-is_video", type=bool, default=IS_VIDEO, help="MusicTransformer or VideoMusicTransformer")
123
+
124
+ if IS_VIDEO:
125
+ parser.add_argument("-vis_models", type=str, default=VIS_MODELS_SORTED, help="...")
126
+ else:
127
+ parser.add_argument("-vis_models", type=str, default="", help="...")
128
+
129
+ parser.add_argument("-emo_model", type=str, default="6c_l14p", help="...")
130
+ parser.add_argument("-rpr", type=bool, default=RPR, help="...")
131
+ return parser.parse_args()
132
+
133
+ def print_eval_args(args):
134
+ print(SEPERATOR)
135
+ print("input_dir_music:", args.input_dir_music)
136
+ print("input_dir_video:", args.input_dir_video)
137
+
138
+ print("model_weights:", args.model_weights)
139
+ print("n_workers:", args.n_workers)
140
+ print("force_cpu:", args.force_cpu)
141
+ print("")
142
+ print("batch_size:", args.batch_size)
143
+ print("")
144
+ print("rpr:", args.rpr)
145
+
146
+ print("max_sequence_midi:", args.max_sequence_midi)
147
+ print("max_sequence_video:", args.max_sequence_video)
148
+ print("max_sequence_chord:", args.max_sequence_chord)
149
+
150
+ print("n_layers:", args.n_layers)
151
+ print("num_heads:", args.num_heads)
152
+ print("d_model:", args.d_model)
153
+ print("")
154
+ print("dim_feedforward:", args.dim_feedforward)
155
+ print(SEPERATOR)
156
+ print("")
157
+
158
+ # parse_generate_args
159
+ def parse_generate_args():
160
+ parser = argparse.ArgumentParser()
161
+ outputpath = "./output_vevo/"+version
162
+ if IS_VIDEO:
163
+ modelpath = "./saved_models/AMT/best_loss_weights.pickle"
164
+ modelpathReg = "./saved_models/AMT/best_rmse_weights.pickle"
165
+ # modelpath = "./saved_models/"+version+ "/"+VIS_MODELS_PATH+"/results/best_acc_weights.pickle"
166
+ # modelpathReg = "./saved_models/"+version+ "/"+VIS_MODELS_PATH+"/results_regression_bigru/best_rmse_weights.pickle"
167
+ else:
168
+ modelpath = "./saved_models/"+version+ "/no_video/results/best_loss_weights.pickle"
169
+ modelpathReg = None
170
+
171
+ parser.add_argument("-dataset_dir", type=str, default="./dataset/", help="Folder of VEVO dataset")
172
+
173
+ parser.add_argument("-input_dir_music", type=str, default="./dataset/vevo_chord/" + MUSIC_TYPE, help="Folder of video CNN feature files")
174
+ parser.add_argument("-input_dir_video", type=str, default="./dataset/vevo_vis", help="Folder of video CNN feature files")
175
+
176
+ parser.add_argument("-output_dir", type=str, default= outputpath, help="Folder to write generated midi to")
177
+
178
+ parser.add_argument("-primer_file", type=str, default=None, help="File path or integer index to the evaluation dataset. Default is to select a random index.")
179
+ parser.add_argument("--force_cpu", action="store_true", help="Forces model to run on a cpu even when gpu is available")
180
+
181
+ parser.add_argument("-target_seq_length_midi", type=int, default=1024, help="Target length you'd like the midi to be")
182
+ parser.add_argument("-target_seq_length_chord", type=int, default=300, help="Target length you'd like the midi to be")
183
+
184
+ parser.add_argument("-num_prime_midi", type=int, default=256, help="Amount of messages to prime the generator with")
185
+ parser.add_argument("-num_prime_chord", type=int, default=30, help="Amount of messages to prime the generator with")
186
+ parser.add_argument("-model_weights", type=str, default=modelpath, help="Pickled model weights file saved with torch.save and model.state_dict()")
187
+ parser.add_argument("-modelReg_weights", type=str, default=modelpathReg, help="Pickled model weights file saved with torch.save and model.state_dict()")
188
+
189
+ parser.add_argument("-beam", type=int, default=0, help="Beam search k. 0 for random probability sample and 1 for greedy")
190
+
191
+ parser.add_argument("-max_sequence_midi", type=int, default=2048, help="Maximum midi sequence to consider")
192
+ parser.add_argument("-max_sequence_video", type=int, default=300, help="Maximum video sequence to consider")
193
+ parser.add_argument("-max_sequence_chord", type=int, default=300, help="Maximum chord sequence to consider")
194
+
195
+ parser.add_argument("-n_layers", type=int, default=6, help="Number of decoder layers to use")
196
+ parser.add_argument("-num_heads", type=int, default=8, help="Number of heads to use for multi-head attention")
197
+ parser.add_argument("-d_model", type=int, default=512, help="Dimension of the model (output dim of embedding layers, etc.)")
198
+ parser.add_argument("-dim_feedforward", type=int, default=1024, help="Dimension of the feedforward layer")
199
+
200
+ parser.add_argument("-is_video", type=bool, default=IS_VIDEO, help="MusicTransformer or VideoMusicTransformer")
201
+
202
+ if IS_VIDEO:
203
+ parser.add_argument("-vis_models", type=str, default=VIS_MODELS_SORTED, help="...")
204
+ else:
205
+ parser.add_argument("-vis_models", type=str, default="", help="...")
206
+
207
+ parser.add_argument("-emo_model", type=str, default="6c_l14p", help="...")
208
+ parser.add_argument("-rpr", type=bool, default=RPR, help="...")
209
+ parser.add_argument("-test_id", type=str, default=None, help="Dimension of the feedforward layer")
210
+
211
+ return parser.parse_args()
212
+
213
+ def print_generate_args(args):
214
+
215
+ print(SEPERATOR)
216
+ print("input_dir_music:", args.input_dir_music)
217
+ print("input_dir_video:", args.input_dir_video)
218
+
219
+ print("output_dir:", args.output_dir)
220
+ print("primer_file:", args.primer_file)
221
+ print("force_cpu:", args.force_cpu)
222
+ print("")
223
+
224
+ print("target_seq_length_midi:", args.target_seq_length_midi)
225
+ print("target_seq_length_chord:", args.target_seq_length_chord)
226
+
227
+ print("num_prime_midi:", args.num_prime_midi)
228
+ print("num_prime_chord:", args.num_prime_chord)
229
+
230
+ print("model_weights:", args.model_weights)
231
+ print("beam:", args.beam)
232
+ print("")
233
+ print("rpr:", args.rpr)
234
+
235
+ print("max_sequence_midi:", args.max_sequence_midi)
236
+ print("max_sequence_video:", args.max_sequence_video)
237
+ print("max_sequence_chord:", args.max_sequence_chord)
238
+
239
+
240
+ print("n_layers:", args.n_layers)
241
+ print("num_heads:", args.num_heads)
242
+ print("d_model:", args.d_model)
243
+ print("")
244
+ print("dim_feedforward:", args.dim_feedforward)
245
+ print("")
246
+ print("test_id:", args.test_id)
247
+
248
+ print(SEPERATOR)
249
+ print("")
250
+
251
+ # write_model_params
252
+ def write_model_params(args, output_file):
253
+ o_stream = open(output_file, "w")
254
+
255
+ o_stream.write("rpr: " + str(args.rpr) + "\n")
256
+ o_stream.write("lr: " + str(args.lr) + "\n")
257
+ o_stream.write("ce_smoothing: " + str(args.ce_smoothing) + "\n")
258
+ o_stream.write("batch_size: " + str(args.batch_size) + "\n")
259
+
260
+ o_stream.write("max_sequence_midi: " + str(args.max_sequence_midi) + "\n")
261
+ o_stream.write("max_sequence_video: " + str(args.max_sequence_video) + "\n")
262
+ o_stream.write("max_sequence_chord: " + str(args.max_sequence_chord) + "\n")
263
+
264
+ o_stream.write("n_layers: " + str(args.n_layers) + "\n")
265
+ o_stream.write("num_heads: " + str(args.num_heads) + "\n")
266
+ o_stream.write("d_model: " + str(args.d_model) + "\n")
267
+ o_stream.write("dim_feedforward: " + str(args.dim_feedforward) + "\n")
268
+ o_stream.write("dropout: " + str(args.dropout) + "\n")
269
+
270
+ o_stream.write("is_video: " + str(args.is_video) + "\n")
271
+ o_stream.write("vis_models: " + str(args.vis_models) + "\n")
272
+ o_stream.write("input_dir_music: " + str(args.input_dir_music) + "\n")
273
+ o_stream.write("input_dir_video: " + str(args.input_dir_video) + "\n")
274
+
275
+ o_stream.close()
utilities/chord_to_midi.py ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ezchord - convert complex chord names to midi notes
2
+
3
+ import sys
4
+ import math
5
+ import argparse
6
+ from enum import Enum, auto
7
+ from midiutil import MIDIFile
8
+
9
+ class Mode(Enum):
10
+ DIM = auto()
11
+ MIN = auto()
12
+ MAJ = auto()
13
+ DOM = auto()
14
+ AUG = auto()
15
+ SUS2 = auto()
16
+ SUS = auto()
17
+ FIVE = auto()
18
+
19
+ TEXT_TO_MODE = {
20
+ "maj": Mode.MAJ,
21
+ "dim": Mode.DIM,
22
+ "o": Mode.DIM,
23
+ "min": Mode.MIN,
24
+ "m": Mode.MIN,
25
+ "-": Mode.MIN,
26
+ "aug": Mode.AUG,
27
+ "+": Mode.AUG,
28
+ "sus2": Mode.SUS2,
29
+ "sus": Mode.SUS,
30
+ "5": Mode.FIVE,
31
+ "five": Mode.FIVE
32
+ }
33
+
34
+ MODE_TO_SHIFT = {
35
+ Mode.MAJ: {3:0, 5:0},
36
+ Mode.DOM: {3:0, 5:0},
37
+ Mode.DIM: {3:-1, 5:-1},
38
+ Mode.MIN: {3:-1, 5:0},
39
+ Mode.AUG: {3:0, 5:1},
40
+ Mode.SUS2: {3:-2, 5:0},
41
+ Mode.SUS: {3:1, 5:0},
42
+ Mode.FIVE: {3:3, 5:0},
43
+ }
44
+
45
+ NOTE_TO_PITCH = {
46
+ "a": 9,
47
+ "b": 11,
48
+ "c": 12,
49
+ "d": 14,
50
+ "e": 16,
51
+ "f": 17,
52
+ "g": 19
53
+ }
54
+
55
+ PITCH_TO_NOTE = {}
56
+
57
+ for note, pitch in NOTE_TO_PITCH.items():
58
+ PITCH_TO_NOTE[pitch] = note
59
+
60
+ RM_TO_PITCH = {
61
+ "vii": 11,
62
+ "iii": 4,
63
+ "vi": 9,
64
+ "iv": 5,
65
+ "ii": 2,
66
+ "i": 0,
67
+ "v": 7
68
+ }
69
+
70
+ ACC_TO_SHIFT = {
71
+ "b": -1,
72
+ "#": 1
73
+ }
74
+
75
+ SCALE_DEGREE_SHIFT = {
76
+ 1: 0,
77
+ 2: 2,
78
+ 3: 4,
79
+ 4: 5,
80
+ 5: 7,
81
+ 6: 9,
82
+ 7: 11
83
+ }
84
+
85
+ def getNumber(string):
86
+ numStr = ""
87
+
88
+ for char in string:
89
+ if char.isdigit():
90
+ numStr += char
91
+
92
+ if len(numStr) > 0:
93
+ return int(numStr)
94
+
95
+ return
96
+
97
+ def textToPitch(text, key = "c", voice = True):
98
+ text = text.lower()
99
+ isLetter = text[0] in NOTE_TO_PITCH.keys()
100
+
101
+ if isLetter:
102
+ pitch = NOTE_TO_PITCH[text[0]]
103
+ else:
104
+ for rm in RM_TO_PITCH.keys():
105
+ if rm in text:
106
+ pitch = RM_TO_PITCH[rm] + textToPitch(key)
107
+ isRomanNumeral = True
108
+ break
109
+
110
+ for i in range(1 if isLetter else 0, len(text)):
111
+ if text[i] in ACC_TO_SHIFT.keys():
112
+ pitch += ACC_TO_SHIFT[text[i]]
113
+
114
+ return pitch
115
+
116
+ def pitchToText(pitch):
117
+ octave = math.floor(pitch / 12)
118
+ pitch = pitch % 12
119
+ pitch = pitch + (12 if pitch < 9 else 0)
120
+ accidental = ""
121
+
122
+ if not (pitch in PITCH_TO_NOTE.keys()):
123
+ pitch = (pitch + 1) % 12
124
+ pitch = pitch + (12 if pitch < 9 else 0)
125
+ accidental = "b"
126
+
127
+ return PITCH_TO_NOTE[pitch].upper() + accidental + str(octave)
128
+
129
+ def degreeToShift(deg):
130
+ return SCALE_DEGREE_SHIFT[(deg - 1) % 7 + 1] + math.floor(deg / 8) * 12
131
+
132
+ def voice(chords):
133
+ center = 0
134
+ voiced_chords = []
135
+ chord_ct = 0
136
+ pChord = None
137
+
138
+ for i, currChord in enumerate(chords):
139
+
140
+ if len(currChord) == 0:
141
+ voiced_chords.append( [] )
142
+ continue
143
+ else:
144
+ if chord_ct == 0:
145
+ voiced_chords.append( currChord )
146
+ chord_ct += 1
147
+ center = currChord[1] + 3
148
+ pChord = currChord
149
+ continue
150
+
151
+ prevChord = pChord
152
+ voiced_chord = []
153
+
154
+ for i_, currNote in enumerate(currChord):
155
+ # Skip bass note
156
+ if i_ == 0:
157
+ prevNote = prevChord[0]
158
+ if abs(currNote - prevNote) > 7:
159
+ if currNote < prevNote and abs(currNote + 12 - prevNote) < abs(currNote - prevNote):
160
+ bestVoicing = currNote + 12
161
+ elif currNote > prevNote and abs(currNote - 12 - prevNote) < abs(currNote - prevNote):
162
+ bestVoicing = currNote - 12
163
+ else:
164
+ bestVoicing = currNote
165
+
166
+ voiced_chord.append(bestVoicing)
167
+ continue
168
+
169
+ bestNeighbor = None
170
+ allowance = -1
171
+
172
+ while bestNeighbor == None:
173
+ allowance += 1
174
+ for i__, prevNote in enumerate(prevChord):
175
+ if i__ == 0:
176
+ continue
177
+
178
+ if (
179
+ abs(currNote - prevNote) % 12 == allowance
180
+ or abs(currNote - prevNote) % 12 == 12 - allowance
181
+ ):
182
+ bestNeighbor = prevNote
183
+ break
184
+
185
+ if currNote <= bestNeighbor:
186
+ bestVoicing = currNote + math.floor((bestNeighbor - currNote + 6) / 12) * 12
187
+ else:
188
+ bestVoicing = currNote + math.ceil((bestNeighbor - currNote - 6) / 12) * 12
189
+
190
+ bestVoicing = bestVoicing if (abs(bestVoicing - center) <= 8 or allowance > 2) else currNote
191
+ voiced_chord.append(bestVoicing)
192
+
193
+
194
+ voiced_chord.sort()
195
+ voiced_chords.append(voiced_chord)
196
+ pChord = voiced_chord
197
+
198
+ return voiced_chords
199
+
200
+ class Chord:
201
+ def __init__(self, string):
202
+ self.string = string
203
+ self.degrees = {}
204
+
205
+ string += " "
206
+ self.split = []
207
+ sect = ""
208
+
209
+ notes = list(NOTE_TO_PITCH.keys())
210
+ rms = list(RM_TO_PITCH.keys())
211
+ accs = list(ACC_TO_SHIFT.keys())
212
+ modes = list(TEXT_TO_MODE.keys())
213
+
214
+ rootAdded = False
215
+ modeAdded = False
216
+
217
+ isRomanNumeral = False
218
+ isSlashChord = False
219
+ isMaj7 = False
220
+
221
+ for i in range(0, len(string) - 1):
222
+ sect += string[i]
223
+ currChar = string[i].lower()
224
+ nextChar = string[i+1].lower()
225
+
226
+ rootFound = not rootAdded and (currChar in notes+rms+accs and not nextChar in rms+accs)
227
+ modeFound = False
228
+ numFound = (currChar.isdigit() and not nextChar.isdigit())
229
+
230
+ if (
231
+ (i == len(string) - 2)
232
+ or rootFound
233
+ or numFound
234
+ or nextChar == "/"
235
+ or currChar == ")"
236
+ ):
237
+ if rootFound:
238
+ self.root = sect
239
+ rootAdded = True
240
+
241
+ isRomanNumeral = self.root in rms
242
+ elif sect[0] == "/":
243
+ # case for 6/9 chords
244
+ if sect[1] == "9":
245
+ self.degrees[9] = 0
246
+ else:
247
+ isSlashChord = True
248
+ self.bassnote = sect[1:len(sect)]
249
+ else:
250
+ if not modeAdded:
251
+ for mode in modes:
252
+ modeFound = mode in sect[0:len(mode)]
253
+ if modeFound:
254
+ self.mode = TEXT_TO_MODE[mode]
255
+ modeAdded = True
256
+ break
257
+
258
+ if not modeAdded:
259
+ if not isRomanNumeral and str(getNumber(sect)) == sect:
260
+ self.mode = Mode.DOM
261
+ modeFound = True
262
+ modeAdded = True
263
+
264
+ deg = getNumber(sect)
265
+ if deg != None:
266
+ shift = 0
267
+
268
+ for char in sect:
269
+ if char == "#":
270
+ shift += 1
271
+ elif char == "b":
272
+ shift -= 1
273
+
274
+ if (not modeFound) or deg % 2 == 0:
275
+ self.degrees[deg] = shift
276
+ elif deg >= 7:
277
+ for i in range(7, deg+1):
278
+ if i % 2 != 0:
279
+ self.degrees[i] = shift
280
+
281
+ self.split.append(sect)
282
+ sect = ""
283
+
284
+ if not modeAdded:
285
+ # Case for minor roman numeral chords
286
+ if self.root in rms and self.root == self.root.lower():
287
+ self.mode = Mode.MIN
288
+ else:
289
+ self.mode = Mode.DOM
290
+
291
+ if not isSlashChord:
292
+ self.bassnote = self.root
293
+
294
+ for sect in self.split:
295
+ isMaj7 = ("maj" in sect) or isMaj7
296
+
297
+ if (7 in self.degrees.keys()) and not isMaj7:
298
+ self.degrees[7] = -1
299
+
300
+ def getMIDI(self, key="c", octave=4):
301
+ notes = {}
302
+
303
+ notes[0] = textToPitch(self.bassnote, key) - 12
304
+
305
+ root = textToPitch(self.root, key)
306
+ notes[1] = root
307
+ notes[3] = root + degreeToShift(3) + MODE_TO_SHIFT[self.mode][3]
308
+ notes[5] = root + degreeToShift(5) + MODE_TO_SHIFT[self.mode][5]
309
+
310
+ for deg in self.degrees.keys():
311
+ notes[deg] = root + degreeToShift(deg) + self.degrees[deg]
312
+
313
+ for deg in notes.keys():
314
+ notes[deg] += 12 * octave
315
+
316
+ return list(notes.values())