-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpreprocessing.py
31 lines (22 loc) · 1.13 KB
/
preprocessing.py
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
import os
from keras.preprocessing.image import ImageDataGenerator
def processing():
if os.path.isfile('DATA/train/.DS_Store'):
os.remove('DATA/train/.DS_Store')
if os.path.isfile('DATA/test/.DS_Store'):
os.remove('DATA/test/.DS_Store')
for i in range(1,80):
if os.path.isfile(f'DATA/train/{i}/.DS_Store'):
os.remove(f'DATA/train/{i}/.DS_Store')
if os.path.isfile(f'DATA/test/{i}/.DS_Store'):
os.remove(f'DATA/test/{i}/.DS_Store')
datagen = ImageDataGenerator(rescale = 1./255,
zoom_range = 0.2)
trained_image = datagen.flow_from_directory('DATA/train',
target_size = (32,32),
class_mode = 'categorical')
test_datagen = ImageDataGenerator(rescale = 1./255)
test_image = test_datagen.flow_from_directory('DATA/test',
target_size = (32,32),
class_mode = 'categorical')
return trained_image , test_image