Downloads · 30 days
0
Gertlek/DetectiveSAMv2
DetectiveSAMv2 is a machine learning model from Gertlek. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
DetectiveSAMv2 is an inference-only image forgery localization bundle built around SAM2. This repo is v2-only: the code path, config sidecar, tests, and demo commands all target the detectivesamv2 checkpoint.
Downloads · 30 days
0
Access
Public
Updated Jul 30, 2026
Repo size
639 MB
Likes
1
Public
Click a slice to open those files.
.pt324 MB · 51%
From the Hugging Face model README
DetectiveSAMv2 is an inference-only image forgery localization bundle built around SAM2. This repo is v2-only: the code path, config sidecar, tests, and demo commands all target the detective_sam_v2 checkpoint.
The full runnable bundle with model weights is hosted on Hugging Face:
checkpoints/sam2configs/demo/cocoglide/, demo/flux_test/, and demo/qwen_test/demo/user_image/demo_input.pngBuilt-in checkpoint alias:
detective_sam_v2The detective_sam_v2 alias expects checkpoints/detective_sam_v2.pth and the bundled YAML sidecar.
This release packages the v2 architecture and benchmarked weights without the old DetectiveSAMv1 compatibility branches.
Main changes:
detectivesam_inference/models/adapters.py.model or ema keys.Scores below are IoU / F1 in percent for the 10-epoch v2 checkpoint dsamv2_best6info_10ep_20260623_060047/best_model.pth. Previous Detective SAM values are measured on the same validation setup. The MagicBrush row uses the MagicBrush test split, not the higher full_magicbrush_val artifact.
| Dataset | DetectiveSAMv2 | Previous Detective SAM | Delta |
|---|---|---|---|
| MagicBrush test | 48.83 / 61.01 | 43.98 / 56.46 | +4.85 / +4.55 |
| SIDA test | 54.95 / 65.24 | 50.22 / 60.49 | +4.73 / +4.76 |
| FLUX-Bench | 44.26 / 56.17 | 18.61 / 25.77 | +25.65 / +30.39 |
| QWEN-Bench | 45.40 / 56.95 | 19.62 / 27.15 | +25.78 / +29.80 |
| CoCoGLIDE | 46.63 / 58.33 | 42.79 / 53.43 | +3.84 / +4.90 |
| AutoSplice | 57.49 / 70.53 | 47.85 / 60.32 | +9.64 / +10.21 |
| NanoBanana | 33.04 / 45.97 | 25.89 / 35.74 | +7.15 / +10.23 |
| Overall | 49.55 / 61.39 | 38.77 / 49.14 | +10.78 / +12.26 |
QWEN-Bench and FLUX-Bench are included because the training mix includes corresponding AutoEditForge-generated QWEN and FLUX datasets.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Then download the large weights from Hugging Face:
pip install -U huggingface_hub
hf download Gertlek/DetectiveSAMv2 \
checkpoints/detective_sam_v2.pth \
sam2configs/sam2.1_hiera_base_plus.pt \
--local-dir .
The expected checkpoint paths are also documented in checkpoints/README.md and sam2configs/README.md.
For the simplest setup, clone the Hugging Face repo directly:
git lfs install
git clone https://huggingface.co/Gertlek/DetectiveSAMv2
cd DetectiveSAMv2
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python -m detectivesam_inference.predict \
--output-dir outputs/poster_baseline
Place your image at demo/user_image/demo_input.png, then run:
python -m detectivesam_inference.predict \
--output-dir outputs/poster_user_image
In this mode the CLI reuses the target image as its own source reference so the demo stays runnable with a single image.
If demo/user_image/demo_input.png is absent, the default predict command falls back to the bundled CocoGlide sample banana_28809.
python -m detectivesam_inference.predict \
--output-dir outputs/poster_baseline
Flux example:
python -m detectivesam_inference.predict \
--checkpoint detective_sam_v2 \
--source demo/flux_test/source/548.png \
--target demo/flux_test/target/548.png \
--mask demo/flux_test/mask/548.png \
--output-dir outputs/poster_flux
Qwen example:
python -m detectivesam_inference.predict \
--checkpoint detective_sam_v2 \
--source demo/qwen_test/source/166.png \
--target demo/qwen_test/target/166.png \
--mask demo/qwen_test/mask/166.png \
--output-dir outputs/poster_qwen
Use this to evaluate the bundled banana and train CocoGlide demo pairs.
python -m detectivesam_inference.evaluate \
--checkpoint detective_sam_v2 \
--dataset-root demo/cocoglide \
--output-dir outputs/poster_eval_cocoglide \
--num-visualizations 2
Each predict run writes a compact set of visual artifacts plus a JSON summary:
<name>_comparison.png<name>_probability.png<name>_pred_mask.png<name>_pred_overlay.png<name>_summary.jsonIf a ground-truth mask is provided, the run also saves:
<name>_gt_mask.png<name>_gt_overlay.pngThe evaluate command writes summary.json plus a few visualization examples under visualizations/.
cuda automatically when available and otherwise runs on CPU.checkpoints/; you only need the alias or checkpoint path..pth checkpoint and SAM2 .pt weight file.