-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoad.py
More file actions
34 lines (30 loc) · 845 Bytes
/
Copy pathLoad.py
File metadata and controls
34 lines (30 loc) · 845 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 tensorflow.keras.preprocessing.image import ImageDataGenerator
# === SETTINGS ===
IMG_SIZE = 48
BATCH_SIZE = 64
DATA_PATH = 'Emotion_dataset'
# === AUGMENTATION & SPLIT ===
datagen = ImageDataGenerator(
rescale=1./255,
validation_split=0.2, # 80% train, 20% validation
horizontal_flip=True
)
# === TRAINING DATA ===
train_generator = datagen.flow_from_directory(
DATA_PATH,
target_size=(IMG_SIZE, IMG_SIZE),
color_mode='grayscale', # grayscale for 48x48 emotion images
batch_size=BATCH_SIZE,
class_mode='categorical',
subset='training'
)
# === VALIDATION DATA ===
val_generator = datagen.flow_from_directory(
DATA_PATH,
target_size=(IMG_SIZE, IMG_SIZE),
color_mode='grayscale',
batch_size=BATCH_SIZE,
class_mode='categorical',
subset='validation'
)