Datasets:

Modalities:
Tabular
Formats:
csv
ArXiv:
Tags:
music
Libraries:
Datasets
pandas
License:
DISCOX commited on
Commit
80e702e
1 Parent(s): ebaed7c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +82 -0
README.md CHANGED
@@ -1,3 +1,85 @@
1
  ---
2
  license: mit
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ tags:
4
+ - music
5
+ pretty_name: FMA rank
6
+ size_categories:
7
+ - 100K<n<1M
8
  ---
9
+
10
+ # What is FMA-rank?
11
+
12
+ FMA is a music dataset from the Free Music Archive, containing over 8000 hours of Creative Commons-licensed music from 107k tracks across 16k artists and 15k albums.
13
+ It was created in 2017 by [Defferrard et al.](https://arxiv.org/abs/1612.01840) in collaboration with [Free Music Archive](https://freemusicarchive.org/).
14
+
15
+ FMA contains a lot of good music, and a lot of bad music, so the question is: can we rank the samples in FMA?
16
+
17
+ FMA-rank is a CLAP-based statistical ranking of each sample in FMA. We calculate the log-likelihood of each sample in FMA belonging to an estimated gaussian in the CLAP latent space, using these values we can rank and filter FMA. In log-likelihood, higher values are better.
18
+
19
+ # Quickstart
20
+
21
+ Download any FMA split from the official github https://github.com/mdeff/fma. Extract the FMA folder from the downloaded zip and set the path to the folder in `fma_root_dir`.
22
+ Run the following code snippet to load and filter the FMA samples according to the given percentages. The code snippet will return a HF audio dataset.
23
+ ```Python
24
+ from datasets import load_dataset, Dataset, Audio
25
+ import os
26
+
27
+ # provide location of fma folder
28
+ fma_root_dir = "/path/to/fma/folder"
29
+
30
+ # provide percentage of fma dataset to use
31
+ # for whole dataset, use start_percentage=0 and end_percentage=100
32
+ # for worst 20% of dataset, use start_percentage=0 and end_percentage=20
33
+ # for best 20% of dataset, use the following values:
34
+ start_percentage = 80
35
+ end_percentage = 100
36
+
37
+ # load fma_rank.csv from huggingface and sort from lowest to highest
38
+ csv_loaded = load_dataset("DISCOX/FMA-rank")
39
+ fma_item_list = csv_loaded["train"]
40
+ fma_sorted_list = sorted(fma_item_list, key=lambda d: d['CLAP-log-likelihood'])
41
+
42
+ def parse_fma_audio_folder(fma_root_dir):
43
+ valid_fma_ids = []
44
+ subfolders = os.listdir(fma_root_dir)
45
+ for subfolder in subfolders:
46
+ subfolder_path = os.path.join(fma_root_dir, subfolder)
47
+ if os.path.isdir(subfolder_path):
48
+ music_files = os.listdir(subfolder_path)
49
+ for music_file in music_files:
50
+ if ".mp3" not in music_file:
51
+ continue
52
+ else:
53
+ fma_id = music_file.split('.')[0]
54
+ valid_fma_ids.append(fma_id)
55
+ return valid_fma_ids
56
+
57
+ # select the existing files according to the provided fma folder
58
+ valid_fma_ids = parse_fma_audio_folder(fma_root_dir)
59
+ df_dict = {"id":[], "score": [], "audio": []}
60
+ for fma_item in fma_sorted_list:
61
+ this_id = f"{fma_item['id']:06d}"
62
+ if this_id in valid_fma_ids:
63
+ df_dict["id"].append(this_id)
64
+ df_dict["score"].append(fma_item["CLAP-log-likelihood"])
65
+ df_dict["audio"].append(os.path.join(fma_root_dir, this_id[:3] , this_id+".mp3"))
66
+
67
+ # filter the fma dataset according to the percentage defined above
68
+ i_start = int(start_percentage * len(df_dict["id"]) / 100)
69
+ i_end = int(end_percentage * len(df_dict["id"]) / 100)
70
+ df_dict_filtered = {
71
+ "id": df_dict["id"][i_start:i_end],
72
+ "score": df_dict["score"][i_start:i_end],
73
+ "audio": df_dict["audio"][i_start:i_end],
74
+ }
75
+
76
+ # get final dataset
77
+ audio_dataset = Dataset.from_dict(df_dict_filtered).cast_column("audio", Audio())
78
+
79
+ """
80
+ Dataset({
81
+ features: ['id', 'score', 'audio'],
82
+ num_rows: 1599
83
+ })
84
+ """
85
+ ```