SafeScan
Overview
SafeScan is a multi-class image classifier designed to detect and categorize NSFW (Not Safe For Work) content in images. Built on top of the google/vit-base-patch16-224 vision transformer backbone, SafeScan classifies visual media across five distinct categories to aid in automated content moderation and platform safety.
The model maps visual inputs to the following labels:
- 0: safe – General, non-explicit content
- 1: drawing – Non-explicit artistic illustrations and drawings
- 2: sexy – Suggestive, provocative, or borderline content
- 3: hentai – Explicit anime/manga or illustrated adult content
- 4: porn – Explicit adult photographic media
Key Features
- Multi-Class Granularity: Differentiates between both real/photographic media and illustrated content across safe, suggestive, and explicit tiers.
- Social Media Compression Robustness: Trained with almost all common social media compression artifacts, ensuring performance stays consistent when analyzing images uploaded across different platforms and formats.
- Vision Transformer Backbone: Leverages
google/vit-base-patch16-224for high-capacity visual representation learning. - Fast and Scalable: Standard patch-based transformer architecture suitable for batch processing and automated moderation pipelines.
Training Details
- Base Model:
google/vit-base-patch16-224 - Dataset Size: 34,000 images (34k)
- Data Augmentation: Comprehensive social media compression augmentations applied during training to guarantee robust real-world inference.
Label Mapping
{
"0": "safe",
"1": "drawing",
"2": "sexy",
"3": "hentai",
"4": "porn"
}
How It Works
- Images are preprocessed and resized according to the ViT input resolution (224×224).
- Patch embeddings and contextual features are extracted via the
google/vit-base-patch16-224backbone. - A classification head outputs probabilities across the 5 target classes.
Demo and Usage
1. Installation
pip install -U transformers torch pillow
2. Loading and Running Inference
from transformers import pipeline
# Load pipeline from Hugging Face
pipe = pipeline("image-classification", model="Parveshiiii/SafeScan")
# Run inference on an image
results = pipe("path/to/image.jpg")
print(results)
Intended Use
- Automated Content Moderation: Filtering or flagging inappropriate imagery on platforms, forums, and communities.
- Safety Pipelines: Pre-screening images before public display or downstream generative processing.
- Assistance Tool: Assisting human moderators by categorizing borderline (
sexy), illustrated (hentai,drawing), and explicit (porn) materials.
Ethical Considerations
- Human-in-the-Loop: Automated moderation should ideally be paired with human review workflows to mitigate false positives and false negatives.
- Context Awareness: The model evaluates image features only; it does not infer contextual intent, regional cultural norms, or artistic context beyond visual classification.
Citation
@misc{SafeScan_Parveshiiii,
title={SafeScan: A Vision Transformer for NSFW Image Classification},
author={Parveshiiii},
publisher={Hugging Face},
year={2025},
url={https://huggingface.co/Parveshiiii/SafeScan}
}
References
- Base Model Backbone: google/vit-base-patch16-224