-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpreprocess.py
More file actions
33 lines (23 loc) · 730 Bytes
/
Copy pathpreprocess.py
File metadata and controls
33 lines (23 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import random
import transform
from transform import CATnDOG, transform
from torch.utils.data import DataLoader
img_file = os.listdir("data/train")
img_file = list(filter(lambda x: x != 'train', img_file))
def train_path(p):
return f"data/train/{p}"
img_file = list(map(train_path, img_file))
# print("Train Images", len(img_file))
random.shuffle(img_file)
train = img_file[:20000]
test = img_file[20000:]
# print(len(train), len(test))
##traindataset
train_ds = CATnDOG(train, transform)
train_dl = DataLoader(train_ds, batch_size=100)
# print(len(train_ds), len(train_dl))
##testdataset
test_ds = CATnDOG(test, transform)
test_dl = DataLoader(test_ds, batch_size=100)
# print(len(test_ds), len(test_dl))