File size: 4,160 Bytes
37fbec9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ─────────────────────────────────────────────────────────────────────────────
# config.yaml  β€”  Central configuration for the Chest X-Ray ViT project
# Optimized for RTX 3050 Laptop GPU (4 GB VRAM)
# ─────────────────────────────────────────────────────────────────────────────

# ── Paths ─────────────────────────────────────────────────────────────────────
paths:
  data_root:       "./data/raw"               # Root where Kaggle data is extracted
  images_dir:      "./data/raw/images"        # Folder containing all .png X-rays
  labels_csv:      "./data/raw/Data_Entry_2017.csv"
  train_list:      "./data/raw/train_val_list.txt"
  test_list:       "./data/raw/test_list.txt"
  checkpoints_dir: "./checkpoints"
  results_dir:     "./results"
  mlflow_dir:      "./experiments/mlflow"

# ── Dataset ───────────────────────────────────────────────────────────────────
dataset:
  image_size: 224                 # ViT-Base-16 expects 224Γ—224
  # Use a fraction of training data for quick iteration on RTX 3050
  # Set to 1.0 for full training, 0.2 for fast smoke-test
  train_fraction: 1.0
  val_split: 0.1                  # 10% of train_val_list used as validation
  num_workers: 0                  # 0 = safe on Windows; increase if Linux
  pin_memory: true

# ── Model ─────────────────────────────────────────────────────────────────────
model:
  name: "google/vit-base-patch16-224-in21k"   # Pre-trained on ImageNet-21k
  num_classes: 14
  dropout: 0.1
  gradient_checkpointing: true    # Saves ~30% VRAM on RTX 3050

# ── Training ──────────────────────────────────────────────────────────────────
training:
  num_epochs: 10                   # Conservative for RTX 3050; increase if time allows
  batch_size: 16                   # Fits in 4 GB VRAM with grad-checkpointing
  gradient_accumulation_steps: 2  # Effective batch = 32
  learning_rate: 2.0e-5           # Typical fine-tune LR for ViT
  weight_decay: 0.01
  warmup_ratio: 0.05              # 5% of total steps for LR warmup
  max_grad_norm: 1.0              # Gradient clipping
  mixed_precision: true           # fp16 β€” mandatory for 4 GB VRAM
  save_best_only: true
  log_interval: 50                # Log every N optimizer steps

# ── Diseases (NIH ChestX-ray14 label set) ─────────────────────────────────────
diseases:
  - "Atelectasis"
  - "Cardiomegaly"
  - "Effusion"
  - "Infiltration"
  - "Mass"
  - "Nodule"
  - "Pneumonia"
  - "Pneumothorax"
  - "Consolidation"
  - "Edema"
  - "Emphysema"
  - "Fibrosis"
  - "Pleural_Thickening"
  - "Hernia"

# ── MLflow ────────────────────────────────────────────────────────────────────
mlflow:
  experiment_name: "chest-xray-vit"
  run_name: "vit-base16-clahe-v1"

# ── Inference / Demo ──────────────────────────────────────────────────────────
inference:
  threshold: 0.5                  # Sigmoid threshold for positive prediction
  gradio_port: 7860
  gradio_share: false             # Set true to get public URL (ngrok)