unsafebench-eval
UnsafeBench: Benchmarking Image Safety Classifiers on Real-World and AI-Generated Images — Qu et al. (2024) (arXiv:2405.03486, 2024)
What this evaluates
Evaluates the effectiveness of image safety classifiers in detecting various unsafe content categories across real-world and AI-generated images. It also probes classifier robustness to distribution shifts caused by artistic representations and grid layouts in AI-generated content.
Datasets
- UnsafeBench — total ?; splits: LAION-5B (Real-World) (-1), Lexica (AI-Generated) (-1)
Metrics
F1-Score(primary) — range: [0, 1]- Harmonic mean of precision and recall, calculated per unsafe category and overall. Precision = TP / (TP + FP), Recall = TP / (TP + FN).
Input / output format
Input: Single images sourced from LAION-5B (real-world) or Lexica (AI-generated), optionally accompanied by text prompts for VLM-based classifiers.
Output: Binary or multi-class safety labels (e.g., safe, hate, harassment, violence, sexual, shocking, illegal activity, deception, political, health, spam) per image.
Scoring recipe
def compute_f1(predictions, gold_labels):
tp = sum(1 for p, g in zip(predictions, gold_labels) if p == 1 and g == 1)
fp = sum(1 for p, g in zip(predictions, gold_labels) if p == 1 and g == 0)
fn = sum(1 for p, g in zip(predictions, gold_labels) if p == 0 and g == 1)
precision = tp / (tp + fp) if (tp + fp) > 0 else 0.0
recall = tp / (tp + fn) if (tp + fn) > 0 else 0.0
return 2 * precision * recall / (precision + recall) if (precision + recall) > 0 else 0.0
Common pitfalls
- Relying on a single prompt for VLM-based classifiers without majority voting, which can drop F1-Score by ~0.10.
- Ignoring distribution shifts between real-world and AI-generated images, leading to overestimation of classifier robustness.
- Overlooking the impact of artistic representations and grid layouts, which cause significant false negatives for models trained only on real-world data.
Evidence (verbatim from paper)
We calculate the overall F1-Score of Q16 combined with NudeNet across the unsafe categories they can cover, and the score is 0.665.
Citation
@misc{qu2024unsafebench,
title={UnsafeBench: Benchmarking Image Safety Classifiers on Real-World and AI-Generated Images},
author={Qu et al. (2024)},
year={2024},
note={arXiv:2405.03486}
}
- arXiv: 2405.03486