Spaces:
Sleeping
Sleeping
| 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 | |