A progressive GPR anomaly detection framework built around a small normal feature bank, full-image patch anomaly scoring, dense score-map construction, connected-component region extraction, and hierarchical false-positive suppression.
PFS-Res-SAM detects subsurface anomalies in GPR B-scans using only a small set of normal reference samples (default: 20 intact images). The pipeline:
- Feature bank construction — extract 2D-ESN dynamic features from normal patches
- Patch-level anomaly scoring — compute patch-wise L2 distance to the normal bank
- Dense score map — project patch scores onto the full image plane
- Connected-region extraction — threshold and segment the score map
- Hierarchical filtering — suppress false positives in resized and original image coordinates
- Image-level scoring — aggregate patch scores for ROC/AUC evaluation
- Python 3.9
- CUDA 11.8 (GPU) or CPU-only
git clone https://github.com/create-meng/PFS-Res-SAM.git
cd PFS-Res-SAMGPU (recommended):
conda create -n pfs-res-sam python=3.9 -y
conda activate pfs-res-sam
pip install -r requirements-gpu.txtCPU:
conda create -n pfs-res-sam python=3.9 -y
conda activate pfs-res-sam
pip install -r requirements-cpu.txtDownload the SAM ViT-L checkpoint (required by the pipeline):
# Linux / WSL
aria2c -x 16 -s 16 -k 1M \
-o sam_vit_l_0b3195.pth \
-d sam \
"https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth"# Windows PowerShell
Invoke-WebRequest -Uri https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth -OutFile sam\sam_vit_l_0b3195.pthThe file should be placed at sam/sam_vit_l_0b3195.pth (~1.2 GB).
Download the GPR dataset from Mendeley Data:
Mojahid et al. (2024) — Intelligent recognition of subsurface utilities and voids: A Ground Penetrating Radar dataset for Deep Learning applications
Expected layout under a data/ directory (create if missing):
data/GPR_data/
├── augmented_intact/ # Normal samples (900 images) — for feature bank + AUC normal pool
├── augmented_cavities/ # Cavity anomalies (553 images, with VOC/YOLO annotations)
└── augmented_utilities/ # Utility-type anomalies (786 images, with VOC/YOLO annotations)
# Step 1: Build feature bank
python experiments/_feature_bank.py
# Step 2: Run inference
python experiments/_inference_auto.py
# Step 3: Evaluate results
python experiments/_evaluate.py
# Or run the full ablation suite
python experiments/run_ablation_main.pyPFS-Res-SAM/
├── PatchRes/ # Core modules
│ ├── ESN_2D_nobatch.py # 2D-ESN implementation
│ ├── PatchRes.py # PatchRes main class
│ ├── ResSAM.py # Res-SAM core module
│ ├── common.py # Nearest-neighbor search (faiss/sklearn)
│ ├── functions.py # Data loading, mask generation
│ ├── logger.py # Logging utilities
│ └── sam_integration.py # SAM integration
├── experiments/ # Pipeline scripts
│ ├── _feature_bank.py # Feature bank construction
│ ├── _inference_auto.py # Fully automatic inference
│ ├── _evaluate.py # Evaluation metrics
│ ├── run_ablation_main.py # Ablation study runner
│ ├── dataset_layout.py # Dataset path management
│ ├── paper_constants.py # Paper-aligned constants
│ └── resize_policy.py # Image resize policy
├── sam/
│ └── sam.py # SAM interface (weight downloaded separately)
├── scripts/ # Setup and batch scripts
├── requirements-cpu.txt # CPU dependencies
├── requirements-gpu.txt # GPU dependencies (CUDA 11.8)
└── README.md
| Parameter | Default | Description |
|---|---|---|
window_size |
50×50 | 2D-ESN patch size |
stride |
5 | Sliding window stride |
hidden_size |
30 | Reservoir size |
beta_threshold (β) |
0.1 | Anomaly threshold (Eq.9) |
init_normal_samples |
20 | Feature bank sample count |
eval IoU threshold |
0.5 | Box matching criterion |
The dataset used in this work is from the Mendeley Data repository by Mojahid et al. (2024), containing 2,239 GPR B-scan images of buried utilities, voids, and intact zones. The current pipeline uses an augmented subset: 900 intact (normal), 553 cavity, and 786 utility-type images.
- Paper: Mojahid, A., El Ouai, D., El Amraoui, K., El Hami, K. & Aitbenamer, H. (2024)
- DOI: 10.17632/ww7fd9t325.1
This project is provided for research and academic use.