Downloads · 30 days
0
pranjal-pravesh/haywoodsloan-ai-image-detector
haywoodsloan-ai-image-detector is a image classification model from pranjal-pravesh. Use it when you need a label for an image. It is set up for onnx.
This repository contains ONNX versions of the haywoodsloan/ai-image-detector-deploy model, which is based on the SwinV2 architecture and fine-tuned for classifying images as artificial (AI-generated) or real.
Downloads · 30 days
0
Access
Public
Updated Mar 6, 2026
Repo size
1 GB
Likes
0
Public
Click a slice to open those files.
.onnx1 GB · 100%
From the Hugging Face model README
This repository contains ONNX versions of the haywoodsloan/ai-image-detector-deploy model, which is based on the SwinV2 architecture and fine-tuned for classifying images as artificial (AI-generated) or real.
Swinv2ForImageClassificationmodel.onnx: FP32 (Full Precision)model_quantized.onnx: QUInt8 (Dynamic Quantization)Testing was performed on an Apple M-series CPU using onnxruntime.
| Model Type | File Size | Latency (Batch 1) | Speedup vs PyTorch | Cosine Similarity |
|---|---|---|---|---|
| Original PyTorch | 745 MB | 234.0 ms | 1.00x | - |
| ONNX FP32 | 763 MB | 151.0 ms | 1.53x | 1.000000 |
| ONNX QUInt8 | 205 MB | 183.8 ms | 1.27x | 0.999992 |
Note: The QUInt8 model provides a ~73% reduction in file size while maintaining extremely high accuracy.
You can use these models with the onnxruntime library.
pip install onnxruntime numpy pillow transformers
import onnxruntime as ort
from transformers import AutoImageProcessor
from PIL import Image
import numpy as np
import torch
# 1. Load the model and processor
model_path = "model_quantized.onnx" # or "model.onnx"
processor = AutoImageProcessor.from_pretrained("haywoodsloan/ai-image-detector-dev-deploy")
session = ort.InferenceSession(model_path, providers=['CPUExecutionProvider'])
# 2. Prepare the image
image = Image.open("path_to_your_image.jpg").convert("RGB")
inputs = processor(images=image, return_tensors="np")
# 3. Run Inference
ort_inputs = {session.get_inputs()[0].name: inputs["pixel_values"]}
logits = session.run(None, ort_inputs)[0]
# 4. Process Outputs
predictions = np.argmax(logits, axis=-1)
labels = ["artificial", "real"]
print(f"Prediction: {labels[predictions[0]]}")
These models were converted using torch.onnx.export (opset 16). The quantized version was generated using dynamic QUInt8 quantization.
A specific fix was applied during quantization to strip intermediate shape annotations (value_info) that were causing conflicts in the SwinV2 graph during the onnxruntime shape inference pass.