UnsafeBench: Benchmarking Image Safety Classifiers on Real-World and AI-Generated Images

Yiting Qu, Xinyue Shen, Yixin Wu, Michael Backes, Savvas Zannettou, Yang Zhang

TL;DR

UnsafeBench is a new benchmarking framework and a meticulously annotated 10K-image dataset designed to evaluate how image safety classifiers perform on both real-world and AI-generated content. The study reveals that AI-generated images possess unique characteristics—like artistic styles and grid layouts—that frequently baffle current safety filters, prompting the authors to release PerspectiveVision, a fine-tuned vision-language model (VLM) that significantly improves moderation accuracy and robustness.

What Problem Does This Paper Address?

As text-to-image models like Stable Diffusion and DALL-E become mainstream, the risk of generating unsafe content (violence, hate speech, etc.) has skyrocketed. Developers rely on "safety classifiers" to filter these images, but there is a major catch: most of these classifiers were trained on real-world datasets.

The authors identify a critical gap: we don't actually know how effective these tools are against AI-generated "unsafe" content. Because AI images have different statistical distributions, noise levels, and visual styles compared to real photos, they might bypass existing safeguards. Furthermore, the robustness of these classifiers against adversarial attacks—intentional tweaks to an image to fool a model—remains largely untested in the context of generative AI.

Methods

The researchers took a multi-pronged approach:

  1. Benchmarking: They evaluated eight classifiers, split into two groups:
  2. Conventional Classifiers: Smaller, specialized models like Q16, NudeNet, and LAION’s NSFW_Detector.
  3. VLM-based Classifiers: Large, general-purpose models like GPT-4V, LLaVA, and InstructBLIP.
  4. Adversarial Testing: They applied standard attacks (FGSM, PGD, and DeepFool) to see how easily these models could be tricked into labeling an unsafe image as "safe."
  5. PerspectiveVision: To solve the identified weaknesses, they built a new moderation tool by fine-tuning LLaVA using LoRA (Low-Rank Adaptation). This allowed the model to learn the specific nuances of AI-generated unsafe content without the massive computational cost of full retraining.
High-level overview of UnsafeBench

Datasets

The authors introduced the UnsafeBench Dataset, which consists of 10,146 annotated images.

  • Sources: Real-world images were pulled from LAION-5B, while AI-generated images were sourced from Lexica (primarily Stable Diffusion outputs).
  • Taxonomy: Images are categorized into 11 unsafe classes based on OpenAI’s content policy, including Hate, Harassment, Self-Harm, and Sexual content.
  • Annotation: Every image was manually reviewed by three experts to ensure high-quality labels, avoiding the noise often found in crowdsourced datasets.

Key Insights and Ideas

  • The "Artistic" Loophole: AI-generated images often use artistic representations (e.g., oil painting styles) or grid layouts (multiple small images in one). The authors found that these characteristics act as natural "cloaks," causing conventional classifiers trained on realistic photos to fail.
  • Imbalanced Vigilance: Classifiers are generally quite good at spotting "Sexual" or "Shocking" content (F1-scores near 0.8) but struggle significantly with "Hate," "Harassment," and "Self-Harm" (F1-scores often below 0.5).
  • AI Images are "Brittle": Interestingly, AI-generated images are more susceptible to adversarial attacks than real-world images. A tiny amount of noise is more likely to flip an AI image's classification from unsafe to safe.
  • VLMs are the New Standard: General-purpose VLMs like GPT-4V are significantly more effective and robust than specialized small models, though they are slower and more expensive to run at scale.
Comparison of F1-Scores on real-world vs AI-generated images

Key Results

  • Top Performer: GPT-4V emerged as the most effective commercial model, achieving the highest F1-scores in nearly all categories.
  • PerspectiveVision Success: The authors' fine-tuned model, PerspectiveVision, achieved an overall F1-score of 0.836 across six different evaluation datasets, outperforming both conventional ensembles and zero-shot VLMs.
  • Robustness Boost: While conventional classifiers showed a "Robust Accuracy" (RA) as low as 0.29 under attack, PerspectiveVision maintained an RA of 0.952 on the UnsafeBench test set.
  • Distribution Shift: Figure 3 highlights that while some models (like MultiHeaded) actually perform better on AI images because they were trained on them, most standard filters (like NSFW_Detector) see a sharp performance drop when moving from real-world to AI content.

Limitations and Future Work

The authors acknowledge several limitations:

  • Keyword Bias: Both safe and unsafe images were collected using the same "unsafe" keywords to create a challenging "borderline" dataset. This might make the benchmark harder than real-world random sampling.
  • Model Diversity: The AI images were mostly from Stable Diffusion. Future versions of the benchmark should include more samples from Midjourney, DALL-E 3, and Flux.
  • Cost of VLMs: While PerspectiveVision is powerful, the computational overhead of using a large VLM for every single image on a high-traffic platform remains a practical hurdle.

The research concludes that as generative AI evolves, our safety tools must move beyond simple pattern matching and toward the deep semantic understanding offered by fine-tuned VLMs.

Summary updated

BibTeX
@inproceedings{qu2025unsafebench,
  author = {Yiting Qu and Xinyue Shen and Yixin Wu and Michael Backes and Savvas Zannettou and Yang Zhang},
  title = {{UnsafeBench: Benchmarking Image Safety Classifiers on Real-World and AI-Generated Images}},
  booktitle = {CCS},
  year = {2025},
  doi = {10.1145/3719027.3765088},
}
Figure