danilotpnta commited on
Commit
faf18d4
·
verified ·
1 Parent(s): 8dfc1d1

Convert dataset to Parquet (#2)

Browse files

- Convert dataset to Parquet (6195b96a00243fa2265b4345b832a3b17d3cd68f)
- Delete data file (e118fb10d2058ba2309e82c16169fcf38d8d8df9)
- Delete data file (8319fd5510ff46a07b1f9a12ecc2989f710ebe49)
- Delete loading script (9e4081e46bcd1f4e98fcc34d64e166171d3c8003)
- Delete data file (7b9c590d6a768b1dcea488cfb91bb3d4bb3e5387)

.gitignore DELETED
@@ -1 +0,0 @@
1
- data/.DS_Store
 
 
GTZAN_genre_classification.py DELETED
@@ -1,114 +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
- "genre": datasets.Value("string"),
43
- "title": datasets.Value("string"),
44
- "artist": datasets.Value("string"),
45
- "tempo": datasets.Value("float"),
46
- "keys": datasets.Value("string"),
47
- "loudness": datasets.Value("float"),
48
- "sorted_pred_genres": datasets.Value("string"),
49
- "x_tsne": datasets.Value("float"),
50
- "y_tsne": datasets.Value("float"),
51
- "z_tsne": datasets.Value("float"),
52
- "x_umap": datasets.Value("float"),
53
- "y_umap": datasets.Value("float"),
54
- "z_umap": datasets.Value("float"),
55
- "album_cover_path": datasets.Value("string"),
56
- "key": datasets.Value("string"),
57
- "filepath": datasets.Value("string"),
58
- }
59
- ),
60
- supervised_keys=("genre", "title"),
61
- homepage=_HOMEPAGE_URL,
62
- citation=_CITATION,
63
- )
64
-
65
- def _split_generators(self, dl_manager):
66
- archive_path = dl_manager.download_and_extract(_DATA_URL)
67
- data_dir = os.path.join(archive_path, "gtzan")
68
-
69
- # Debugging the paths
70
- logger.info(f"Archive path: {archive_path}")
71
- logger.info(f"Data directory: {data_dir}")
72
-
73
- return [
74
- datasets.SplitGenerator(
75
- name=datasets.Split.TRAIN,
76
- gen_kwargs={
77
- "metadata_file": os.path.join(data_dir, "metadata.csv"),
78
- "data_dir": data_dir,
79
- },
80
- ),
81
- ]
82
-
83
- def _generate_examples(self, metadata_file, data_dir):
84
- with open(metadata_file, "r", encoding="utf-8") as f:
85
- reader = csv.DictReader(f)
86
- for id_, row in enumerate(reader):
87
- # Correct the file paths by removing the 'data/' prefix
88
- file_path = os.path.join(data_dir, row["filepath"].replace("data/gtzan/", ""))
89
- album_cover_path = os.path.join(data_dir, row["album_cover_path"].replace("data/gtzan/", ""))
90
-
91
- # Debugging the file paths
92
- logger.info(f"Processing file: {file_path}")
93
- if not os.path.exists(file_path):
94
- logger.error(f"File not found: {file_path}")
95
-
96
- yield id_, {
97
- "id": int(row["id"]),
98
- "genre": row["genre"],
99
- "title": row["title"],
100
- "artist": row["artist"],
101
- "tempo": float(row["tempo"]),
102
- "keys": row["keys"],
103
- "loudness": float(row["loudness"]),
104
- "sorted_pred_genres": row["sorted_pred_genres"],
105
- "x_tsne": float(row["x_tsne"]),
106
- "y_tsne": float(row["y_tsne"]),
107
- "z_tsne": float(row["z_tsne"]),
108
- "x_umap": float(row["x_umap"]),
109
- "y_umap": float(row["y_umap"]),
110
- "z_umap": float(row["z_umap"]),
111
- "album_cover_path": album_cover_path,
112
- "key": row["key"],
113
- "filepath": file_path,
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,3 +1,52 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
1
  ---
2
  license: mit
3
+ dataset_info:
4
+ config_name: gtzan
5
+ features:
6
+ - name: id
7
+ dtype: int32
8
+ - name: genre
9
+ dtype: string
10
+ - name: title
11
+ dtype: string
12
+ - name: artist
13
+ dtype: string
14
+ - name: tempo
15
+ dtype: float32
16
+ - name: keys
17
+ dtype: string
18
+ - name: loudness
19
+ dtype: float32
20
+ - name: sorted_pred_genres
21
+ dtype: string
22
+ - name: x_tsne
23
+ dtype: float32
24
+ - name: y_tsne
25
+ dtype: float32
26
+ - name: z_tsne
27
+ dtype: float32
28
+ - name: x_umap
29
+ dtype: float32
30
+ - name: y_umap
31
+ dtype: float32
32
+ - name: z_umap
33
+ dtype: float32
34
+ - name: album_cover_path
35
+ dtype: string
36
+ - name: key
37
+ dtype: string
38
+ - name: filepath
39
+ dtype: string
40
+ splits:
41
+ - name: train
42
+ num_bytes: 680045
43
+ num_examples: 999
44
+ download_size: 209606
45
+ dataset_size: 680045
46
+ configs:
47
+ - config_name: gtzan
48
+ data_files:
49
+ - split: train
50
+ path: gtzan/train-*
51
+ default: true
52
  ---
data/gtzan.zip → gtzan/train-00000-of-00001.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:aeaec9a21c64eec0fffc3823641178a13f2c71001010e36423c2fc22ce8b12c9
3
+ size 209606
metadata.csv DELETED
The diff for this file is too large to render. See raw diff