-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
79 lines (65 loc) · 2.68 KB
/
Copy pathconfig.py
File metadata and controls
79 lines (65 loc) · 2.68 KB
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
78
79
import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
class Config:
SECRET_KEY = os.environ.get("SECRET_KEY", os.urandom(32).hex())
# Database
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(BASE_DIR, "screenings.db")
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Upload settings
UPLOAD_FOLDER = os.path.join(BASE_DIR, "uploads")
MAX_CONTENT_LENGTH = 10 * 1024 * 1024 # 10 MB
ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg"}
# Model settings
MODEL_PATH = os.path.join(BASE_DIR, "models", "malaria_detector.keras")
IMAGE_SIZE = (300, 300)
THRESHOLD_PATH = os.path.join(BASE_DIR, "models", "optimal_threshold.txt")
# Grad-CAM settings
GRADCAM_FOLDER = os.path.join(BASE_DIR, "static", "gradcam")
GRADCAM_MAX_AGE = 3600 # seconds before auto-cleanup
# -----------------------------------------------------------------------
# Symptom scoring — clinically weighted
# -----------------------------------------------------------------------
# Individual symptom weights (based on WHO malaria diagnostic criteria)
SYMPTOM_WEIGHTS = {
# Primary indicators (classic malaria triad)
"fever": 3.0,
"chills": 2.5,
"sweating": 2.5,
# Secondary indicators
"headache": 1.5,
"nausea": 1.5,
"fatigue": 1.0,
"muscle_aches": 1.5,
"joint_pain": 1.0,
"diarrhea": 1.0,
# Severe malaria indicators
"jaundice": 3.0,
# Risk context (not symptoms but increase prior probability)
"travel": 2.5,
"previous_malaria": 1.5,
}
MAX_SYMPTOM_SCORE = sum(SYMPTOM_WEIGHTS.values())
# Bonus when classic malaria triad is present together
# Fever + chills + sweating occurring together is highly specific to malaria
TRIAD_BONUS = 3.0
# -----------------------------------------------------------------------
# Risk aggregation
# -----------------------------------------------------------------------
# Base weights for combining ML prediction with symptom score
ML_WEIGHT = 0.65
SYMPTOM_WEIGHT = 0.35
# When ML is highly confident (above this threshold), increase ML weight
ML_HIGH_CONFIDENCE = 0.85
# When classic triad is present but ML says negative, add this override
# (could be early-stage infection not yet visible in smear)
TRIAD_OVERRIDE_BOOST = 0.15
# Risk level thresholds
RISK_LOW_THRESHOLD = 0.30
RISK_HIGH_THRESHOLD = 0.60
# Age-based risk multipliers (children <5 and elderly are most vulnerable)
AGE_RISK_MULTIPLIERS = {
"child_under_5": 1.25,
"child_5_14": 1.10,
"adult_15_60": 1.0,
"elderly_over_60": 1.15,
}