projectlosangeles commited on
Commit
9b04778
1 Parent(s): 07856ec

Upload 9 files

Browse files
Los_Angeles_MIDI_Dataset_Metadata_Maker.ipynb CHANGED
@@ -83,6 +83,7 @@
83
  "import statistics\n",
84
  "import random\n",
85
  "from collections import Counter\n",
 
86
  "\n",
87
  "from tqdm import tqdm\n",
88
  "\n",
@@ -186,7 +187,7 @@
186
  "print('Randomizing file list...')\n",
187
  "random.shuffle(filez)\n",
188
  "\n",
189
- "TMIDIX.Tegridy_Any_Pickle_File_Writer(filez, '/content/drive/MyDrive/filez')"
190
  ]
191
  },
192
  {
@@ -199,7 +200,7 @@
199
  "outputs": [],
200
  "source": [
201
  "#@title Load file list\n",
202
- "filez = TMIDIX.Tegridy_Any_Pickle_File_Reader('/content/drive/MyDrive/filez')\n",
203
  "print('Done!')"
204
  ]
205
  },
@@ -480,6 +481,86 @@
480
  "print('=' * 70)"
481
  ]
482
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
  {
484
  "cell_type": "markdown",
485
  "metadata": {
 
83
  "import statistics\n",
84
  "import random\n",
85
  "from collections import Counter\n",
86
+ "import pickle\n",
87
  "\n",
88
  "from tqdm import tqdm\n",
89
  "\n",
 
187
  "print('Randomizing file list...')\n",
188
  "random.shuffle(filez)\n",
189
  "\n",
190
+ "TMIDIX.Tegridy_Any_Pickle_File_Writer(filez, '/content/filez')"
191
  ]
192
  },
193
  {
 
200
  "outputs": [],
201
  "source": [
202
  "#@title Load file list\n",
203
+ "filez = TMIDIX.Tegridy_Any_Pickle_File_Reader('/content/filez')\n",
204
  "print('Done!')"
205
  ]
206
  },
 
481
  "print('=' * 70)"
482
  ]
483
  },
484
+ {
485
+ "cell_type": "markdown",
486
+ "source": [
487
+ "# (BUILD FINAL METADATA FILE)"
488
+ ],
489
+ "metadata": {
490
+ "id": "rr1IA9GwAybn"
491
+ }
492
+ },
493
+ {
494
+ "cell_type": "code",
495
+ "source": [
496
+ "#@title Build final metadata file\n",
497
+ "full_path_to_metadata_pickle_files = \"/content/drive/MyDrive\" #@param {type:\"string\"}\n",
498
+ "\n",
499
+ "print('=' * 70)\n",
500
+ "print('Los Angeles MIDI Dataset Metadata File Builder')\n",
501
+ "print('=' * 70)\n",
502
+ "print('Searching for files...')\n",
503
+ "\n",
504
+ "filez = list()\n",
505
+ "for (dirpath, dirnames, filenames) in os.walk(full_path_to_metadata_pickle_files):\n",
506
+ " filez += [os.path.join(dirpath, file) for file in filenames if file.split('.')[-1] == 'pickle']\n",
507
+ "print('=' * 70)\n",
508
+ "\n",
509
+ "filez.sort()\n",
510
+ "\n",
511
+ "print('Loading metadata files... Please wait...')\n",
512
+ "print('=' * 70)\n",
513
+ "\n",
514
+ "metadata = []\n",
515
+ "\n",
516
+ "for f in tqdm(filez):\n",
517
+ "\n",
518
+ " metadata.extend(pickle.load(open(f, 'rb')))\n",
519
+ " print('Done!')\n",
520
+ " print('=' * 70)\n",
521
+ " print('Loaded file:', f)\n",
522
+ " print('=' * 70)\n",
523
+ " \n",
524
+ "print('Done!')\n",
525
+ "print('=' * 70)\n",
526
+ "print('Randomizing metadata entries order...')\n",
527
+ "random.shuffle(metadata)\n",
528
+ "print('=' * 70)\n",
529
+ "print('Writing final metadata pickle file...Please wait...')\n",
530
+ "\n",
531
+ "with open('/content/LAMDa_META_DATA.pickle', 'wb') as handle:\n",
532
+ " pickle.dump(metadata, handle, protocol=pickle.HIGHEST_PROTOCOL)\n",
533
+ "\n",
534
+ "print('=' * 70)\n",
535
+ "print('Done!')\n",
536
+ "print('=' * 70)"
537
+ ],
538
+ "metadata": {
539
+ "cellView": "form",
540
+ "id": "_uGS9wJGBoEF"
541
+ },
542
+ "execution_count": null,
543
+ "outputs": []
544
+ },
545
+ {
546
+ "cell_type": "code",
547
+ "source": [
548
+ "#@title Zip final metadata file\n",
549
+ "print('=' * 70)\n",
550
+ "print('Zipping... Please wait...')\n",
551
+ "print('=' * 70)\n",
552
+ "!zip LAMDa_META_DATA.zip LAMDa_META_DATA.pickle\n",
553
+ "print('=' * 70)\n",
554
+ "print('Done!')\n",
555
+ "print('=' * 70)"
556
+ ],
557
+ "metadata": {
558
+ "cellView": "form",
559
+ "id": "tnEgu3uYEX0a"
560
+ },
561
+ "execution_count": null,
562
+ "outputs": []
563
+ },
564
  {
565
  "cell_type": "markdown",
566
  "metadata": {
los_angeles_midi_dataset_metadata_maker.py CHANGED
@@ -37,6 +37,7 @@ import math
37
  import statistics
38
  import random
39
  from collections import Counter
 
40
 
41
  from tqdm import tqdm
42
 
@@ -92,10 +93,10 @@ if filez == []:
92
  print('Randomizing file list...')
93
  random.shuffle(filez)
94
 
95
- TMIDIX.Tegridy_Any_Pickle_File_Writer(filez, '/content/drive/MyDrive/filez')
96
 
97
  #@title Load file list
98
- filez = TMIDIX.Tegridy_Any_Pickle_File_Reader('/content/drive/MyDrive/filez')
99
  print('Done!')
100
 
101
  """# (PROCESS)"""
@@ -358,4 +359,57 @@ print('=' * 70)
358
  print('Total good processed MIDI files:', files_count)
359
  print('=' * 70)
360
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  """# Congrats! You did it! :)"""
 
37
  import statistics
38
  import random
39
  from collections import Counter
40
+ import pickle
41
 
42
  from tqdm import tqdm
43
 
 
93
  print('Randomizing file list...')
94
  random.shuffle(filez)
95
 
96
+ TMIDIX.Tegridy_Any_Pickle_File_Writer(filez, '/content/filez')
97
 
98
  #@title Load file list
99
+ filez = TMIDIX.Tegridy_Any_Pickle_File_Reader('/content/filez')
100
  print('Done!')
101
 
102
  """# (PROCESS)"""
 
359
  print('Total good processed MIDI files:', files_count)
360
  print('=' * 70)
361
 
362
+ """# (BUILD FINAL METADATA FILE)"""
363
+
364
+ #@title Build final metadata file
365
+ full_path_to_metadata_pickle_files = "/content/drive/MyDrive" #@param {type:"string"}
366
+
367
+ print('=' * 70)
368
+ print('Los Angeles MIDI Dataset Metadata File Builder')
369
+ print('=' * 70)
370
+ print('Searching for files...')
371
+
372
+ filez = list()
373
+ for (dirpath, dirnames, filenames) in os.walk(full_path_to_metadata_pickle_files):
374
+ filez += [os.path.join(dirpath, file) for file in filenames if file.split('.')[-1] == 'pickle']
375
+ print('=' * 70)
376
+
377
+ filez.sort()
378
+
379
+ print('Loading metadata files... Please wait...')
380
+ print('=' * 70)
381
+
382
+ metadata = []
383
+
384
+ for f in tqdm(filez):
385
+
386
+ metadata.extend(pickle.load(open(f, 'rb')))
387
+ print('Done!')
388
+ print('=' * 70)
389
+ print('Loaded file:', f)
390
+ print('=' * 70)
391
+
392
+ print('Done!')
393
+ print('=' * 70)
394
+ print('Randomizing metadata entries order...')
395
+ random.shuffle(metadata)
396
+ print('=' * 70)
397
+ print('Writing final metadata pickle file...Please wait...')
398
+
399
+ with open('/content/LAMDa_META_DATA.pickle', 'wb') as handle:
400
+ pickle.dump(metadata, handle, protocol=pickle.HIGHEST_PROTOCOL)
401
+
402
+ print('=' * 70)
403
+ print('Done!')
404
+ print('=' * 70)
405
+
406
+ #@title Zip final metadata file
407
+ print('=' * 70)
408
+ print('Zipping... Please wait...')
409
+ print('=' * 70)
410
+ !zip LAMDa_META_DATA.zip LAMDa_META_DATA.pickle
411
+ print('=' * 70)
412
+ print('Done!')
413
+ print('=' * 70)
414
+
415
  """# Congrats! You did it! :)"""