-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the Spatial Mask Merging (SMM) wiki!
This space provides extended documentation, background, and usage examples for the SMM framework.
Spatial Mask Merging (SMM) implements a paper-faithful ILP-based correlation clustering algorithm for merging overlapping instance segmentation masks across image tiles.
It was developed for research in large-scale aerial/remote-sensing imagery and general dense instance detection.
- Overview
- Installation
- Running SMM
- Visualization
- Evaluation
- Optimization
- Known Limitations
- Citation & License
Clone the repository and install dependencies:
git clone https://github.com/mihajlov39547/spatial-mask-merging.git
cd spatial-mask-merging
pip install -r requirements.txt
# Optional extras
pip install torch pulp optuna rtree opencv-python-headless matplotlibTo merge overlapping instance masks:
python smm/smm.py --pred_dir /path/to/predictions --out_dir ./merged_jsonsNotes:
-
--iou_threshcontrols the box-level IoU threshold. -
--mask_iou_threshcontrols mask-level overlap merging. - Set
--method ilpfor exact correlation clustering (default).
Visualize merged predictions or ground truth annotations:
python tools/visualization.py --pred_dir /path/to/pred_jsons --image_dir /path/to/imagesEach image will produce a *_visualization.pdf overlay for qualitative inspection.
Evaluate merged results against ground truth:
python tools/evaluation.py --pred_dir ./merged_preds --gt_dir ./gt_json --img_dir ./images --out_csv ./results/eval.csvOutputs include:
- Precision, Recall, F1, Dice, PQ
- Average Fragments, Count Error, Mean Error
Use the built-in Optuna optimizer to tune merging thresholds:
python tools/optimize_smm.py --pred_dir ./preds --gt_dir ./gt_json --n_trials 50The optimizer runs correlation clustering for multiple parameter sets and reports the best-performing configuration.
- Limited testing on large-scale datasets (iSAID, DIOR).
- ILP backend (
pulp) can be slow for high-resolution images. - Visualization scripts assume consistent annotation formats.
If you use this code in your research, please cite:
Marko Mihajlović, Spatial Mask Merging (SMM), 2025.
Copyright (c) 2025 Marko Mihajlović, with contributions from Marina Marjanović.
Licensed under the MIT License.
Spatial Mask Merging (SMM) – v0.1.0-alpha
Paper-faithful ILP-based correlation clustering for spatial instance mask fusion
© 2025 Marko Mihajlović · with contributions from Marina Marjanović
Licensed under the MIT License |
GitHub Repository |
Releases