danilotpnta commited on
Commit
3b5354c
1 Parent(s): c968e8c

Convert dataset to Parquet (#9)

Browse files

- Convert dataset to Parquet (b5b3d351c5370501a2b79fba8ccceed1f67886fe)
- Delete loading script (9954eea637812477cd5488498c088f2550bd267d)
- Delete data file (f0408e7e6180c2eeea89917247bdca3edd4a18ea)

GTZAN_genre_classification.py DELETED
@@ -1,116 +0,0 @@
1
- import os
2
- import csv
3
- import datasets
4
-
5
- logger = datasets.logging.get_logger(__name__)
6
-
7
- _CITATION = """\
8
- @misc{gtzan2023,
9
- title={GTZAN Music Genre Classification Dataset},
10
- author={Your Name},
11
- year={2023},
12
- url={https://example.com},
13
- }
14
- """
15
-
16
- _DESCRIPTION = """\
17
- The GTZAN dataset is a music genre classification dataset.
18
- It consists of 10 genres, each represented by 100 tracks.
19
- """
20
-
21
- _HOMEPAGE_URL = "https://example.com"
22
- _DATA_URL = "data/gtzan.zip"
23
-
24
- class GTZANConfig(datasets.BuilderConfig):
25
- """BuilderConfig for GTZAN"""
26
-
27
- def __init__(self, **kwargs):
28
- super(GTZANConfig, self).__init__(**kwargs)
29
-
30
-
31
- class GTZAN(datasets.GeneratorBasedBuilder):
32
- BUILDER_CONFIGS = [
33
- GTZANConfig(name="gtzan", version=datasets.Version("1.0.0"), description="GTZAN Music Genre Classification Dataset")
34
- ]
35
-
36
- def _info(self):
37
- return datasets.DatasetInfo(
38
- description=_DESCRIPTION,
39
- features=datasets.Features(
40
- {
41
- "id": datasets.Value("int32"),
42
- "audio": datasets.Audio(sampling_rate=44100),
43
- "genre": datasets.Value("string"),
44
- "title": datasets.Value("string"),
45
- "artist": datasets.Value("string"),
46
- "tempo": datasets.Value("float"),
47
- "keys": datasets.Value("string"),
48
- "loudness": datasets.Value("float"),
49
- "sorted_pred_genres": datasets.Value("string"),
50
- "x_tsne": datasets.Value("float"),
51
- "y_tsne": datasets.Value("float"),
52
- "z_tsne": datasets.Value("float"),
53
- "x_umap": datasets.Value("float"),
54
- "y_umap": datasets.Value("float"),
55
- "z_umap": datasets.Value("float"),
56
- # "album_cover_path": datasets.Value("string"),
57
- # "key": datasets.Value("string"),
58
- # "filepath": datasets.Value("string"),
59
- }
60
- ),
61
- supervised_keys=("genre", "title"),
62
- homepage=_HOMEPAGE_URL,
63
- citation=_CITATION,
64
- )
65
-
66
- def _split_generators(self, dl_manager):
67
- archive_path = dl_manager.download_and_extract(_DATA_URL)
68
- data_dir = os.path.join(archive_path, "gtzan")
69
-
70
- # Debugging the paths
71
- logger.info(f"Archive path: {archive_path}")
72
- logger.info(f"Data directory: {data_dir}")
73
-
74
- return [
75
- datasets.SplitGenerator(
76
- name=datasets.Split.TRAIN,
77
- gen_kwargs={
78
- "metadata_file": os.path.join(data_dir, "metadata.csv"),
79
- "data_dir": data_dir,
80
- },
81
- ),
82
- ]
83
-
84
- def _generate_examples(self, metadata_file, data_dir):
85
- with open(metadata_file, "r", encoding="utf-8") as f:
86
- reader = csv.DictReader(f)
87
- for id_, row in enumerate(reader):
88
- # Correct the file paths by removing the 'data/gtzan/' prefix
89
- file_path = os.path.join(data_dir, row["filepath"].replace("data/gtzan/", ""))
90
- album_cover_path = os.path.join(data_dir, row["album_cover_path"].replace("data/gtzan/", ""))
91
-
92
- # Debugging the file paths
93
- logger.info(f"Processing file: {file_path}")
94
- if not os.path.exists(file_path):
95
- logger.error(f"File not found: {file_path}")
96
-
97
- yield id_, {
98
- "id": int(row["id"]),
99
- "audio": file_path, # Include the audio path next to the ID
100
- "genre": row["genre"],
101
- "title": row["title"],
102
- "artist": row["artist"],
103
- "tempo": float(row["tempo"]),
104
- "keys": row["keys"],
105
- "loudness": float(row["loudness"]),
106
- "sorted_pred_genres": row["sorted_pred_genres"],
107
- "x_tsne": float(row["x_tsne"]),
108
- "y_tsne": float(row["y_tsne"]),
109
- "z_tsne": float(row["z_tsne"]),
110
- "x_umap": float(row["x_umap"]),
111
- "y_umap": float(row["y_umap"]),
112
- "z_umap": float(row["z_umap"]),
113
- # "album_cover_path": album_cover_path,
114
- # "key": row["key"],
115
- # "filepath": file_path,
116
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -35,18 +35,12 @@ dataset_info:
35
  dtype: float32
36
  - name: z_umap
37
  dtype: float32
38
- - name: album_cover_path
39
- dtype: string
40
- - name: key
41
- dtype: string
42
- - name: filepath
43
- dtype: string
44
  splits:
45
  - name: train
46
- num_bytes: 1323465590.0
47
  num_examples: 999
48
- download_size: 1305799028
49
- dataset_size: 1323465590.0
50
  configs:
51
  - config_name: gtzan
52
  data_files:
 
35
  dtype: float32
36
  - name: z_umap
37
  dtype: float32
 
 
 
 
 
 
38
  splits:
39
  - name: train
40
+ num_bytes: 1323109027.0
41
  num_examples: 999
42
+ download_size: 1305734429
43
+ dataset_size: 1323109027.0
44
  configs:
45
  - config_name: gtzan
46
  data_files:
data/gtzan.zip → gtzan/train-00000-of-00003.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0e62a3b63c083298de9d7238edd74c4f2c4908d81c6514ef9d1f421f1c87f9ba
3
- size 1244166188
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2a19b0c8cd445a81aecbdd1b852bebd537cbcd50d6d691cdef84e3082e100833
3
+ size 440616185
gtzan/train-00001-of-00003.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb1f9b32a44d48e8080a1391cbb25cba37a8a50d6657556cdc267206ced15e4a
3
+ size 429077505
gtzan/train-00002-of-00003.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2765faff5c6d28916f5079d138c659c1242eeab82bf09c4a1e96a9daf84b633
3
+ size 436040739