All projects

Inpainting forgery detection and localization

Can a small pretrained forgery detector find AI-inpainted regions it was never trained on?

Summary

Out of the box, PSCC-Net cannot tell edited images from real ones, but it partly finds where the edit is. It works much better on Photoshop edits than on Stable Diffusion edits.

Year
2026
Role
PSCC-Net evaluation and dataset preparation
Duration
2 months
Tools
Python, PyTorch, Jupyter
Inpainting forgery detection and localization: cover image

Predicted mask compared with the true edit

  • Found: edited area the model marked correctly
  • False alarm: marked as edited, but untouched
  • Missed: edited area the model didn't mark

Key results

The problem

Inpainting tools such as Stable Diffusion or Photoshop can replace part of a photo so that the edit is hard to see. In a course project on data readiness and AI evaluation, our team of five benchmarked small models for spotting these edits, all under the same protocol. Each model gives two answers: is the image edited (detection), and where (a pixel mask, localization).

I was responsible for PSCC-Net, a CNN with 3.67M parameters built for image manipulation detection and localization. My question was simple: how well does it work out of the box, on a kind of edit it was never trained on?

What I did

  1. Found and prepared the dataset. I located and downloaded TGIF, which pairs MS-COCO photos with inpainted versions and ground-truth masks, and checked it for data leakage.
  2. Adapted the official PSCC-Net inference code to work with TGIF and ran it on my laptop CPU: 5,145 images per setting, about 5 seconds per image, with a script that can resume after interruptions.
  3. Measured detection (accuracy, precision, recall, F1, ROC-AUC) and compared it with a baseline that always answers “edited”.
  4. Experimented with localization settings: the official mask threshold (0.5) against a lower one (0.2), and an open gate (always produce a mask) against a closed gate (only produce a mask when the detector says “edited”).
  5. Checked how stable the numbers are with three resamples of the test set.

Results

Detection is at chance level. ROC-AUC is 0.498. Accuracy 0.657 and F1 0.786 look reasonable on their own, but a baseline that always says “edited” reaches F1 0.960, because most test images are edited.

Localization is partly useful. With a mask threshold of 0.2, macro IoU (overlap between the predicted and the real edited area, from 0 to 1) is 0.335, against 0.210 with the official 0.5. PSCC-Net does much better on Photoshop edits (IoU 0.451) than on Stable Diffusion edits (0.218). By object category, IoU ranges from 0.12 (skis) to 0.56 (zebra). Gating the mask on the detector lowers IoU to 0.242.

Dot plot of localization IoU per object category, from skis (about 0.12) to zebra (about 0.56), with error bars

What I learned