ONNX Model Zoo

pranjal-pravesh/haywoodsloan-ai-image-detector

By pranjal-pravesh · ↓ 0 · ♥ 0 · Updated 2026-03-06

What's in this repo

This page lists the files in pranjal-pravesh/haywoodsloan-ai-image-detector, including model.onnx, model_int8.onnx.

  • 2 ONNX models (.onnx files)
  • 4 files, including 2 .onnx, 1 .md
  • Last updated 2026-03-06

ONNX files

File Size Download
model.onnx — Download
model_int8.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

SwinV2 AI Image Detector (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.

Model Details

  • Architecture: Swinv2ForImageClassification
  • Precision:
    • model.onnx: FP32 (Full Precision)
    • model_quantized.onnx: QUInt8 (Dynamic Quantization)
  • Input Size: 3x256x256
  • Num Labels: 2 (artificial, real)

Performance Metrics (CPU Inference)

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.

How to use (Inference)

You can use these models with the onnxruntime library.

Installation

pip install onnxruntime numpy pillow transformers

Python Inference Code

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]]}")

Conversion and Quantization

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.


license: mit

Model info

onnx image-classification transformers swinv2 ai-detection base_model:haywoodsloan/ai-image-detector-deploy base_model:quantized:haywoodsloan/ai-image-detector-deploy region:us
↓ 0 ♥ 0

Created: 2026-03-06

Updated: 2026-03-06

View on Hugging Face

Files (4)

.gitattributes
README.md
model.onnx ONNX
model_int8.onnx ONNX

Related models