Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,129 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: image-segmentation
|
| 6 |
+
tags:
|
| 7 |
+
- manipulation
|
| 8 |
+
- forgery
|
| 9 |
+
- image
|
| 10 |
+
- cnn
|
| 11 |
+
- transformer
|
| 12 |
+
- residual-noise
|
| 13 |
+
- efficientnet
|
| 14 |
+
- swin
|
| 15 |
+
- localization
|
| 16 |
+
---
|
| 17 |
+
# NGIML Model Card
|
| 18 |
+
|
| 19 |
+
## Inference
|
| 20 |
+
|
| 21 |
+
NGIML performs single-image forgery localization from a pretrained checkpoint and an input RGB image.
|
| 22 |
+
|
| 23 |
+
## Checkpoints
|
| 24 |
+
|
| 25 |
+
Pretrained checkpoints are hosted on Hugging Face:
|
| 26 |
+
|
| 27 |
+
[juhenes/ngiml](https://huggingface.co/juhenes/ngiml)
|
| 28 |
+
|
| 29 |
+
Available checkpoints:
|
| 30 |
+
|
| 31 |
+
- `casia-effnet.pt`
|
| 32 |
+
- `casia-effnet+noise.pt`
|
| 33 |
+
- `casia-effnet+swin.pt`
|
| 34 |
+
- `casia-full.pt`
|
| 35 |
+
- `casia-swin.pt`
|
| 36 |
+
- `casia-swin+noise.pt`
|
| 37 |
+
|
| 38 |
+
## Run Inference
|
| 39 |
+
|
| 40 |
+
### Recommended: Google Colab
|
| 41 |
+
|
| 42 |
+
The easiest way to test the model is through Colab:
|
| 43 |
+
|
| 44 |
+
- Google Colab: [Open `infer.ipynb` in Colab](https://colab.research.google.com/github/juhenes/ngiml-infer/blob/main/infer.ipynb)
|
| 45 |
+
|
| 46 |
+
This is the recommended path for quick testing because the notebook is already set up for checkpoint-based inference.
|
| 47 |
+
|
| 48 |
+
### Local CLI
|
| 49 |
+
|
| 50 |
+
If you want to run the project locally, use the repository files here:
|
| 51 |
+
|
| 52 |
+
- GitHub: [juhenes/ngiml-infer](https://github.com/juhenes/ngiml-infer)
|
| 53 |
+
|
| 54 |
+
Install the dependencies:
|
| 55 |
+
|
| 56 |
+
```bash
|
| 57 |
+
pip install -r requirements.txt
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Run the CLI:
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
python predict.py --checkpoint /path/to/checkpoint.pt --image /path/to/image.png
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
Example:
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
python predict.py --checkpoint checkpoints_cache/casia-full.pt --image /path/to/image.png
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
If `--output-dir` is omitted, outputs are saved under `outputs/<image-stem>/`.
|
| 73 |
+
|
| 74 |
+
## Optional Arguments
|
| 75 |
+
|
| 76 |
+
- `--output-dir` to choose where outputs are saved
|
| 77 |
+
- `--threshold` to override the default binary threshold
|
| 78 |
+
- `--normalization-mode` to set `imagenet` or `zero_one`
|
| 79 |
+
- `--resize-max-side` to resize large images before preprocessing
|
| 80 |
+
- `--crop-size` to override the inference crop size
|
| 81 |
+
- `--device` to choose a device such as `cpu` or `cuda:0`
|
| 82 |
+
|
| 83 |
+
## Output Files
|
| 84 |
+
|
| 85 |
+
When an output directory is used, the runtime saves:
|
| 86 |
+
|
| 87 |
+
- `input_rgb.png`
|
| 88 |
+
- `preview_input_rgb.png`
|
| 89 |
+
- `preview_probability_map.png`
|
| 90 |
+
- `preview_binary_mask.png`
|
| 91 |
+
- `preview_overlay.png`
|
| 92 |
+
- `probability_map.png`
|
| 93 |
+
- `binary_mask.png`
|
| 94 |
+
- `overlay.png`
|
| 95 |
+
- `prediction.json`
|
| 96 |
+
|
| 97 |
+
`prediction.json` includes summary metadata such as the checkpoint path, threshold, normalization mode, device, and basic prediction statistics.
|
| 98 |
+
|
| 99 |
+
## References
|
| 100 |
+
|
| 101 |
+
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)
|
| 102 |
+
|
| 103 |
+
```bibtex
|
| 104 |
+
@inproceedings{Dong2013,
|
| 105 |
+
doi = {10.1109/chinasip.2013.6625374},
|
| 106 |
+
url = {https://doi.org/10.1109/chinasip.2013.6625374},
|
| 107 |
+
year = {2013},
|
| 108 |
+
month = jul,
|
| 109 |
+
publisher = {{IEEE}},
|
| 110 |
+
author = {Jing Dong and Wei Wang and Tieniu Tan},
|
| 111 |
+
title = {{CASIA} Image Tampering Detection Evaluation Database},
|
| 112 |
+
booktitle = {2013 {IEEE} China Summit and International Conference on Signal and Information Processing}
|
| 113 |
+
}
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
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.
|
| 117 |
+
|
| 118 |
+
```bibtex
|
| 119 |
+
@article{pham2019hybrid,
|
| 120 |
+
title = {Hybrid Image-Retrieval Method for Image-Splicing Validation},
|
| 121 |
+
author = {Pham, Nam Thanh and Lee, Jong-Weon and Kwon, Goo-Rak and Park, Chun-Su},
|
| 122 |
+
journal = {Symmetry},
|
| 123 |
+
volume = {11},
|
| 124 |
+
number = {1},
|
| 125 |
+
pages = {83},
|
| 126 |
+
year = {2019},
|
| 127 |
+
publisher = {Multidisciplinary Digital Publishing Institute}
|
| 128 |
+
}
|
| 129 |
+
```
|