-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadData.py
26 lines (20 loc) · 1.21 KB
/
loadData.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
import tensorflow as tf
data_dir = 'Data'
test_data_dir = 'testData'
def load_data():
datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1 / 255,
validation_split=0.2)
train_dataset = datagen.flow_from_directory(data_dir,
target_size=(224, 224),
batch_size=32,
class_mode='binary',
subset='training')
valid_dataset = datagen.flow_from_directory(data_dir,
target_size=(224, 224),
batch_size=32,
class_mode='binary',
subset='validation')
test_datagen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1 / 255)
test_dataset = test_datagen.flow_from_directory(test_data_dir, target_size=(224, 224), class_mode='binary',
subset='training')
return train_dataset, valid_dataset, test_dataset