Image auto-moderation: how to fix violations while preserving the quantity and quality of content

Vladimir Morozov16 Feb 2025

Problem

A classifieds platform moderates every photo in every listing. Photos with violations were blocked or sent back for replacement, and uncertain cases went to manual moderation, which is expensive and can take hours. Rejections cut the amount of published content, because many sellers never republish the fixed listing. Contacts on photos (QR codes, logins, phones, emails) are the most frequent violation: about 1% of photos. Load averages 1,500 requests per second, peaks at 10,000, and a verdict is needed within about a second.

Example from the article: a listing with one photo showing a phone number on a car door. Deleting that photo empties the listing.

Solution in brief

A two-stage service: a fast classifier drops the photos without contacts, a detector finds boxes around the contacts, and the boxes are repaired. Blurring was tried first and was replaced by inpainting (the LaMa model), which erases the contact and restores the background. Latency was held down with request batching, OpenCV preprocessing and model conversion to TensorRT or TorchScript.

Questions this case answers
  • How to automatically fix policy violations inside user-uploaded images, rather than reject the whole item, under a hard latency limit at high request rates
  • How to choose a generative image-restoration model for production when every automatic quality metric can be gamed and speed matters as much as quality
  • How to remove contact details and other forbidden content from listing photos automatically instead of rejecting the whole listing?
  • How to moderate images at thousands of requests per second within a latency budget of about a second?

Tools and methods

  • EfficientNetV2-S classifier — filters out photos without contacts, tuned for recall
  • YOLO detector — finds boxes with contacts, tuned for precision
  • LaMa inpainting — removes the detected object and restores the background
  • Aqueduct, OpenCV, TorchScript, TensorRT — batching, fast preprocessing and fast inference
  • Segment Anything (SAM) — planned step that turns a box into a tighter mask
Continue reading — it's free

Google or a one-time email code. No password.