AI SeedbankHelp preserve open and free AI for humanity's future

← All models

AdamCodd_vit-base-nsfw-detector

AdamCodd · View on Hugging Face ↗

Get this model

Download TorrentMagnet Link

Seeders: 2 · Leechers: 0

Observed 2026-09-05T20:48:33Z across trackers.

Model card

The complete upstream card, rendered from this payload's README.md — the same hash-verified bytes the torrent distributes. Images and off-site links are removed; the original card on Hugging Face carries them.


metrics:

  • accuracy pipeline_tag: image-classification base_model: google/vit-base-patch16-384 model-index:
  • name: AdamCodd/vit-base-nsfw-detector results:
    • task: type: image-classification name: Image Classification metrics:
      • type: accuracy value: 0.9654 name: Accuracy
      • type: AUC value: 0.9948
      • type: loss value: 0.0937 name: Loss

license: apache-2.0 tags:

  • transformers.js
  • transformers
  • nlp

vit-base-nsfw-detector

This model is a fine-tuned version of vit-base-patch16-384 on around 25_000 images (drawings, photos...). It achieves the following results on the evaluation set:

  • Loss: 0.0937
  • Accuracy: 0.9654

New [07/30]: I created a new ViT model specifically to detect NSFW/SFW images for stable diffusion usage (read the disclaimer below for the reason): AdamCodd/vit-nsfw-stable-diffusion.

Disclaimer: This model wasn't made with generative images in mind! There is no generated image in the dataset used here, and it performs significantly worse on generative images, which will require another ViT model specifically trained on generative images. Here are the model's actual scores for generative images to give you an idea:

  • Loss: 0.3682 (↑ 292.95%)
  • Accuracy: 0.8600 (↓ 10.91%)
  • F1: 0.8654
  • AUC: 0.9376 (↓ 5.75%)
  • Precision: 0.8350
  • Recall: 0.8980

Model description

The Vision Transformer (ViT) is a transformer encoder model (BERT-like) pretrained on a large collection of images in a supervised fashion, namely ImageNet-21k, at a resolution of 224x224 pixels. Next, the model was fine-tuned on ImageNet (also referred to as ILSVRC2012), a dataset comprising 1 million images and 1,000 classes, at a higher resolution of 384x384.

Intended uses & limitations

There are two classes: SFW and NSFW. The model has been trained to be restrictive and therefore classify "sexy" images as NSFW. That is, if the image shows cleavage or too much skin, it will be classified as NSFW. This is normal.

Usage for a local image:

from transformers import pipeline
from PIL import Image

img = Image.open("<path_to_image_file>")
predict = pipeline("image-classification", model="AdamCodd/vit-base-nsfw-detector")
predict(img)

Usage for a distant image:

from transformers import ViTImageProcessor, AutoModelForImageClassification
from PIL import Image
import requests

url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
processor = ViTImageProcessor.from_pretrained('AdamCodd/vit-base-nsfw-detector')
model = AutoModelForImageClassification.from_pretrained('AdamCodd/vit-base-nsfw-detector')
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits

predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])
# Predicted class: sfw

Usage with Transformers.js (Vanilla JS):

/* Instructions:
* - Place this script in an HTML file using the <script type="module"> tag.
* - Ensure the HTML file is served over a local or remote server (e.g., using Python's http.server, Node.js server, or similar).
* - Replace 'https://example.com/path/to/image.jpg' in the classifyImage function call with the URL of the image you want to classify.
*
* Example of how to include this script in HTML:
* <script type="module" src="path/to/this_script.js"></script>
*
* This setup ensures that the script can use imports and perform network requests without CORS issues.
*/
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';

// Since we will download the model from HuggingFace Hub, we can skip the local model check
env.allowLocalModels = false;

// Load the image classification model
const classifier = await pipeline('image-classification', 'AdamCodd/vit-base-nsfw-detector');

// Function to fetch and classify an image from a URL
async function classifyImage(url) {
  try {
    const response = await fetch(url);
    if (!response.ok) throw new Error('Failed to load image');

    const blob = await response.blob();
    const image = new Image();
    const imagePromise = new Promise((resolve, reject) => {
      image.onload = () => resolve(image);
      image.onerror = reject;
      image.src = URL.createObjectURL(blob);
    });

    const img = await imagePromise; // Ensure the image is loaded
    const classificationResults = await classifier([img.src]); // Classify the image
    console.log('Predicted class: ', classificationResults[0].label);
  } catch (error) {
    console.error('Error classifying image:', error);
  }
}

// Example usage
classifyImage('https://example.com/path/to/image.jpg');
// Predicted class: sfw

The model has been trained on a variety of images (realistic, 3D, drawings), yet it is not perfect and some images may be wrongly classified as NSFW when they are not. Additionally, please note that using the quantized ONNX model within the transformers.js pipeline will slightly reduce the model's accuracy. You can find a toy implementation of this model with Transformers.js here.

Training and evaluation data

More information needed

Training procedure

Training hyperparameters

The following hyperparameters were used during training:

  • learning_rate: 3e-05
  • train_batch_size: 32
  • eval_batch_size: 32
  • seed: 42
  • optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
  • num_epochs: 1

Training results

  • Validation Loss: 0.0937
  • Accuracy: 0.9654,
  • AUC: 0.9948

Confusion matrix (eval):

[1076 37]

[ 60 1627]

Framework versions

  • Transformers 4.36.2
  • Evaluate 0.4.1

If you want to support me, you can here.

Magnet link

Opens the swarm directly in your torrent client — no file download needed. Copy-paste works too:

magnet:?xt=urn:btih:810290234ecd162590ac3bc3ad173dd1ecb76588&dn=AdamCodd_vit-base-nsfw-detector

Open magnet in torrent client · infohash 810290234ecd162590ac3bc3ad173dd1ecb76588

Files & hashes

PathSizesha1sha256
README.md5.9 KB (6,033 B)ad6d2f31979d8711e9d39c7db1fd39d3eea30298325e88a63de1d94f1f31dcf69b07e8e302723ab8fc5ae2c2f9cdd7963acc753f
config.json715 B (715 B)a0056028b3560268dee912af113b2bb88590fe93604d1da5e3cc8b6dc3f2768a911ed61a44a331cfcee9ecde2ce2cba9a1e7972b
confusion_matrix.png38.3 KB (39,169 B)fa247b63adfd337e52e77505dcf3f2412607648f9d90a34e82d207137a086e04f6eaab2122fb932c624856d218ef88977fff4c8d
model.safetensors328.4 MB (344,391,328 B)3583a8e288d65f4afc78552282121dea718aa0f6266efb8bf67c1e865a577222fbbd6ddb149b9e00ba0d2b50466a034837f026a4
onnx/config.json691 B (691 B)bd35e2c741426966204483159e303596aaf12f4e5f54e0e96c0b5b77caba7e79aebe0b4fa5c154cabf6df65eb1b939ae8b265cfa
onnx/preprocessor_config.json327 B (327 B)0ee5ed3923d0714f6069c7b517555c5c3fc6ca88d77ca5b19fe076679f60e57a1a684cfcfd39a626d50cfabf06a915d039f794ed
preprocessor_config.json232 B (232 B)61411426b69969522fd22e2cbd60b49b530cbf2cf2ca775909d2237bd31440280cefcaceb3ac66753c19f7a344e385e68982a9b2

Cite this release

Canonical URL
https://aiseedbank.org/models/AdamCodd_vit-base-nsfw-detector/
Slug
AdamCodd_vit-base-nsfw-detector
Infohash
810290234ecd162590ac3bc3ad173dd1ecb76588
License
apache-2.0
Signing key fingerprint
85a3b32c3712427b

Every file carries a locally computed sha256 — verify a download against the signed sums: AdamCodd_vit-base-nsfw-detector.SHA256SUMS (+ minisign signature).

Provenance

Upstream repositoryAdamCodd/vit-base-nsfw-detector
Revision (pinned)8587de998f441aac03fdd57a85d2e4cb808c7d64
Fetched at2026-08-24T11:46:17Z
License at fetchapache-2.0
Snapshot toolhuggingface · seedbank 0.1.0

Trackers

✓ verified · rehash-vs-hf-metadata at 2026-08-24T11:46:28Z

apache-2.0328.5 MB (344,438,495 bytes)transformers.jsonnxsafetensorsvitimage-classificationtransformersnlpmodel-index