| --- |
| license: apache-2.0 |
| language: |
| - en |
| pipeline_tag: image-segmentation |
| tags: |
| - manipulation |
| - forgery |
| - image |
| - cnn |
| - transformer |
| - residual-noise |
| - efficientnet |
| - swin |
| - localization |
| --- |
| # NGIML Model Card |
|
|
| ## Inference |
|
|
| NGIML performs single-image forgery localization from a pretrained checkpoint and an input RGB image. |
|
|
| ## Checkpoints |
|
|
| Pretrained checkpoints are hosted on Hugging Face: |
|
|
| [juhenes/ngiml](https://huggingface.co/juhenes/ngiml) |
|
|
| Available checkpoints: |
|
|
| - `casia-effnet.pt` |
| - `casia-effnet+noise.pt` |
| - `casia-effnet+swin.pt` |
| - `casia-full.pt` |
| - `casia-swin.pt` |
| - `casia-swin+noise.pt` |
|
|
| ## Run Inference |
|
|
| ### Recommended: Google Colab |
|
|
| The easiest way to test the model is through Colab: |
|
|
| - Google Colab: [Open `infer.ipynb` in Colab](https://colab.research.google.com/github/juhenes/ngiml-infer/blob/main/infer.ipynb) |
|
|
| This is the recommended path for quick testing because the notebook is already set up for checkpoint-based inference. |
|
|
| ### Local CLI |
|
|
| If you want to run the project locally, use the repository files here: |
|
|
| - GitHub: [juhenes/ngiml-infer](https://github.com/juhenes/ngiml-infer) |
|
|
| Install the dependencies: |
|
|
| ```bash |
| pip install -r requirements.txt |
| ``` |
|
|
| Run the CLI: |
|
|
| ```bash |
| python predict.py --checkpoint /path/to/checkpoint.pt --image /path/to/image.png |
| ``` |
|
|
| Example: |
|
|
| ```bash |
| python predict.py --checkpoint checkpoints_cache/casia-full.pt --image /path/to/image.png |
| ``` |
|
|
| If `--output-dir` is omitted, outputs are saved under `outputs/<image-stem>/`. |
|
|
| ## Optional Arguments |
|
|
| - `--output-dir` to choose where outputs are saved |
| - `--threshold` to override the default binary threshold |
| - `--normalization-mode` to set `imagenet` or `zero_one` |
| - `--resize-max-side` to resize large images before preprocessing |
| - `--crop-size` to override the inference crop size |
| - `--device` to choose a device such as `cpu` or `cuda:0` |
|
|
| ## Output Files |
|
|
| When an output directory is used, the runtime saves: |
|
|
| - `input_rgb.png` |
| - `preview_input_rgb.png` |
| - `preview_probability_map.png` |
| - `preview_binary_mask.png` |
| - `preview_overlay.png` |
| - `probability_map.png` |
| - `binary_mask.png` |
| - `overlay.png` |
| - `prediction.json` |
|
|
| `prediction.json` includes summary metadata such as the checkpoint path, threshold, normalization mode, device, and basic prediction statistics. |
|
|
| ## References |
|
|
| 1. Dong, J., Wang, W., and Tan, T. "CASIA Image Tampering Detection Evaluation Database." 2013 IEEE China Summit and International Conference on Signal and Information Processing, 2013. [DOI](https://doi.org/10.1109/chinasip.2013.6625374) |
|
|
| ```bibtex |
| @inproceedings{Dong2013, |
| doi = {10.1109/chinasip.2013.6625374}, |
| url = {https://doi.org/10.1109/chinasip.2013.6625374}, |
| year = {2013}, |
| month = jul, |
| publisher = {{IEEE}}, |
| author = {Jing Dong and Wei Wang and Tieniu Tan}, |
| title = {{CASIA} Image Tampering Detection Evaluation Database}, |
| booktitle = {2013 {IEEE} China Summit and International Conference on Signal and Information Processing} |
| } |
| ``` |
|
|
| 2. Pham, N. T., Lee, J.-W., Kwon, G.-R., and Park, C.-S. "Hybrid Image-Retrieval Method for Image-Splicing Validation." Symmetry, 11(1), 83, 2019. |
|
|
| ```bibtex |
| @article{pham2019hybrid, |
| title = {Hybrid Image-Retrieval Method for Image-Splicing Validation}, |
| author = {Pham, Nam Thanh and Lee, Jong-Weon and Kwon, Goo-Rak and Park, Chun-Su}, |
| journal = {Symmetry}, |
| volume = {11}, |
| number = {1}, |
| pages = {83}, |
| year = {2019}, |
| publisher = {Multidisciplinary Digital Publishing Institute} |
| } |
| ``` |