import os class Config: # ── Paths ────────────────────────────────────────────────────────────── ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) DATA_DIR = os.path.join(ROOT_DIR, "data") UTKFACE_DIR = os.path.join(DATA_DIR, "UTKFace") MODEL_DIR = os.path.join(ROOT_DIR, "models") MODEL_PATH = os.path.join(MODEL_DIR, "face_model.pth") BEST_MODEL_PATH = os.path.join(MODEL_DIR, "face_model_best.pth") # ── Dataset ──────────────────────────────────────────────────────────── # UTKFace filename: [age]_[gender]_[race]_[datetime].jpg # Race codes: 0=White, 1=Black, 2=Asian, 3=Indian, 4=Others TARGET_RACES = [0, 1, 3] # White + Black (≈US), Indian MIN_AGE = 1 MAX_AGE = 90 TRAIN_RATIO = 0.80 VAL_RATIO = 0.10 # remaining 0.10 → test # ── Training ─────────────────────────────────────────────────────────── IMG_SIZE = 224 BATCH_SIZE = 32 NUM_EPOCHS = 30 LR = 1e-4 LR_STEP = 10 # StepLR step size LR_GAMMA = 0.5 WEIGHT_DECAY = 1e-4 PATIENCE = 7 # early-stopping patience NUM_WORKERS = 4 SEED = 42 # Loss weights (gender is classification; age is regression normalised 0-1) GENDER_LOSS_WEIGHT = 1.0 AGE_LOSS_WEIGHT = 5.0 # scale up because MAE lives in [0,1] # ── Labels ───────────────────────────────────────────────────────────── GENDER_LABELS = ["Male", "Female"] # ── Inference ────────────────────────────────────────────────────────── FACE_CONFIDENCE = 0.7 # minimum face-detection confidence