-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocess.py
More file actions
34 lines (27 loc) · 749 Bytes
/
Copy pathpreprocess.py
File metadata and controls
34 lines (27 loc) · 749 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
33
34
import os
from PIL import Image
from array import *
from random import shuffle
import glob
from sklearn.model_selection import train_test_split
import cv2
width = 64
height = 64
train_data = '/home/super/janjua/inv-layer-classification/URDU/train/'
test_data = '/home/super/janjua/inv-layer-classification/URDU/val/'
x = []
y = []
for i in glob.glob(train_data+'*/*'):
img = cv2.imread(i)
label = i.split('/')[-2]
x.append(img)
y.append(label)
for i in glob.glob(test_data+'*/*'):
img = cv2.imread(i)
label = i.split('/')[-2]
x.append(img)
y.append(label)
assert len(x) == len(y)
def get_split():
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.33, random_state=42)
return (x_train, x_test),(y_train, y_test)