Datasets:
mickylan2367
commited on
Commit
•
176bf54
1
Parent(s):
3bab5ed
Update README
Browse files
README.md
CHANGED
@@ -9,6 +9,8 @@ task_categories:
|
|
9 |
|
10 |
## 基本情報
|
11 |
* sampling_rate: int = 44100
|
|
|
|
|
12 |
|
13 |
## 使い方
|
14 |
### 0: データセットをダウンロード
|
@@ -18,11 +20,42 @@ data = load_dataset("mickylan2367/spectrogram")
|
|
18 |
data = data["train"]
|
19 |
```
|
20 |
|
21 |
-
### 1:
|
|
|
|
|
22 |
```py
|
23 |
-
from
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
```
|
27 |
|
28 |
## 参考資料とメモ
|
|
|
9 |
|
10 |
## 基本情報
|
11 |
* sampling_rate: int = 44100
|
12 |
+
* 20秒のwavファイル -> 1600×800のpngファイルへ変換
|
13 |
+
* librosaの規格により、画像の縦軸:(0-10000?), 画像の横軸:(0-40秒)
|
14 |
|
15 |
## 使い方
|
16 |
### 0: データセットをダウンロード
|
|
|
20 |
data = data["train"]
|
21 |
```
|
22 |
|
23 |
+
### 1: データローダーへ
|
24 |
+
* まだテストデータと検証データは用意していないので、コメントアウトしています
|
25 |
+
* こんな感じの関数で、データローダーにできます。
|
26 |
```py
|
27 |
+
from torchvision import transforms
|
28 |
+
from torch.utils.data import DataLoader
|
29 |
+
|
30 |
+
def load_datasets():
|
31 |
+
data_transforms = [
|
32 |
+
transforms.Resize((IMG_SIZE, IMG_SIZE)),
|
33 |
+
transforms.ToTensor(), # Scales data into [0,1]
|
34 |
+
transforms.Lambda(lambda t: (t * 2) - 1) # Scale between [-1, 1]
|
35 |
+
]
|
36 |
+
data_transform = transforms.Compose(data_transforms)
|
37 |
+
|
38 |
+
train = load_dataset("mickylan2367/spectrogram", split="train")
|
39 |
+
# test = load_dataset("mickylan2367/spectrogram", split="test")
|
40 |
+
# validation = load_dataset("mickylan2367/spectrogram", split="validation")
|
41 |
+
|
42 |
+
for idx in range(len(train["image"])):
|
43 |
+
train["image"][idx] = data_transform(train["image"][idx])
|
44 |
+
# test["image"][idx] = data_transform(test["image"][idx])
|
45 |
+
# validation["image"][idx] = data_transform(validation["image"][idx])
|
46 |
+
|
47 |
+
train = Dataset.from_dict(train)
|
48 |
+
# test = Dataset.from_dict(test)
|
49 |
+
# validation = Dataset.from_dict(validation)
|
50 |
+
|
51 |
+
train = train.with_format("torch") # リスト型回避
|
52 |
+
# test = test.with_format("torch")
|
53 |
+
# validation = validation.with_format(validation)
|
54 |
+
|
55 |
+
torch.utils.data.ConcatDataset([train, test])
|
56 |
+
|
57 |
+
return torch.utils.data.ConcatDataset([train, validation, test])
|
58 |
+
|
59 |
```
|
60 |
|
61 |
## 参考資料とメモ
|