Spaces:
Sleeping
Sleeping
File size: 1,768 Bytes
e5abc2e |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
"""
Configuration settings for the Emotion Recognition System.
"""
import os
from pathlib import Path
# Project paths
PROJECT_ROOT = Path(__file__).parent.parent
DATA_DIR = PROJECT_ROOT / "data"
TRAIN_DIR = DATA_DIR / "train"
TEST_DIR = DATA_DIR / "test"
MODELS_DIR = PROJECT_ROOT / "models"
# Create models directory if it doesn't exist
MODELS_DIR.mkdir(exist_ok=True)
# Image settings
IMAGE_SIZE = (48, 48)
IMAGE_SIZE_TRANSFER = (96, 96) # For transfer learning models
NUM_CHANNELS = 1 # Grayscale
NUM_CHANNELS_RGB = 3 # For transfer learning
# Emotion classes (7 classes from FER dataset)
EMOTION_CLASSES = [
"angry",
"disgusted",
"fearful",
"happy",
"neutral",
"sad",
"surprised"
]
NUM_CLASSES = len(EMOTION_CLASSES)
# Emotion to index mapping
EMOTION_TO_IDX = {emotion: idx for idx, emotion in enumerate(EMOTION_CLASSES)}
IDX_TO_EMOTION = {idx: emotion for idx, emotion in enumerate(EMOTION_CLASSES)}
# Training hyperparameters
BATCH_SIZE = 64
EPOCHS = 50
LEARNING_RATE = 0.001
LEARNING_RATE_FINE_TUNE = 0.0001
VALIDATION_SPLIT = 0.2
# Data augmentation parameters
AUGMENTATION_CONFIG = {
"rotation_range": 15,
"width_shift_range": 0.1,
"height_shift_range": 0.1,
"horizontal_flip": True,
"zoom_range": 0.1,
"brightness_range": (0.9, 1.1),
"fill_mode": "nearest"
}
# Model save paths
CUSTOM_CNN_PATH = MODELS_DIR / "custom_cnn.h5"
MOBILENET_PATH = MODELS_DIR / "mobilenet_v2.h5"
VGG_PATH = MODELS_DIR / "vgg19.h5"
# Training callbacks
EARLY_STOPPING_PATIENCE = 10
REDUCE_LR_PATIENCE = 5
REDUCE_LR_FACTOR = 0.5
# Intensity thresholds
INTENSITY_HIGH_THRESHOLD = 0.8
INTENSITY_MEDIUM_THRESHOLD = 0.5
# API settings
API_HOST = "0.0.0.0"
API_PORT = 8000
# Streamlit settings
STREAMLIT_PORT = 8501
|