Run this model with HF Jobs
Run onnx-community/AI-Anime-Image-Detector-ViT-ONNX on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/onnx-community/AI-Anime-Image-Detector-ViT-ONNX. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/onnx-community/AI-Anime-Image-Detector-ViT-ONNX on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use onnx-community/AI-Anime-Image-Detector-ViT-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use onnx-community/AI-Anime-Image-Detector-ViT-ONNX with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-classification', 'onnx-community/AI-Anime-Image-Detector-ViT-ONNX');
AI-Anime-Image-Detector-ViT (ONNX)
This is an ONNX version of legekka/AI-Anime-Image-Detector-ViT. It was automatically converted and uploaded using this Hugging Face Space.
Usage with Transformers.js
See the pipeline documentation for image-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.ImageClassificationPipeline
AI Anime Image Detector ViT
This is a proof of concept model for detecting anime style AI images. Using Vision Transformer, it was trained on 1M human-made real and 217K AI generated anime images. During training either type appeared in equal amount to avoid biases. The model was trained on a single RTX 3090 GPU for about 40 hours, ~35 epochs.
The training logs are available on my wandb.
Evaluation
Each checkpoint was evaluated on 500-500 real and AI images.
Final result:
- Training Loss: 0.1009
- Eval Loss: 0.1386
It seems like using random crops helped the model to generalize better, however, the training dataset only contained 512x512 images, which meant that every cropped image had bilinear interpolation. Training the model on 1024x1024 images could probably further improve its performance. (Maybe I'll do it later)
Performance comparison
We did a small eval test with ~5000 images on the current available AI image detectors. Note that these models were not specificly trained on anime images.
| Model | Accuracy |
|---|---|
| dima806/ai_vs_real_image_detection | 35,97% |
| Organika/sdxl-detector | 43,29% |
| Nahrawy/AIorNot | 64,74% |
| jacoballessio/ai-image-detect-distilled | 68,94% |
| umm-maybe/AI-image-detector | 75,45% |
| mmanikanta/VIT_AI_image_detector | 79,65% |
| legekka/AI-Anime-Image-Detector-HD-ViT WIP | 94,26% |
| legekka/AI-Anime-Image-Detector-ViT (Ours) | 94,68% |
Usage
Example inference code:
from transformers import AutoModelForImageClassification, AutoFeatureExtractor
import torch
from PIL import Image
model = AutoModelForImageClassification.from_pretrained("legekka/AI-Anime-Image-Detector-ViT")
feature_extractor = AutoFeatureExtractor.from_pretrained("legekka/AI-Anime-Image-Detector-ViT")
model.eval()
image = Image.open("example.jpg")
inputs = feature_extractor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
label = model.config.id2label[torch.argmax(logits).item()]
confidence = torch.nn.functional.softmax(logits, dim=1)[0][torch.argmax(logits)].item()
print(f"Prediction: {label} ({round(confidence * 100)}%)")
- Downloads last month
- 171
Model tree for onnx-community/AI-Anime-Image-Detector-ViT-ONNX
Base model
legekka/AI-Anime-Image-Detector-ViT