ai-image-detector-deploy (ONNX)

ONNX conversion of haywoodsloan/ai-image-detector-deploy (SwinV2-base, Apache 2.0, by Sloan Haywood) at revision 4ae1822603cb1ec980c217cfde1ef1b8e0477a16, for in-browser use by the AI Lens extension with transformers.js / onnxruntime-web. The weights are unchanged apart from the numeric format. All credit for the model goes to its author.

Files

File Format Size Drift vs PyTorch (268 images)
onnx/model_fp16.onnx fp16 weights; LayerNorm, Softmax and other sensitive ops kept fp32; float32 input and output 393 MB max 0.016 in P(AI), no flips at 0.90
onnx/model_uint8.onnx dynamic quantisation of MatMul weights only (uint8); Conv kept float 199 MB mean 0.01, max 0.52, 1 flip at 0.90

Export: torch.onnx.export, opset 17, input pixel_values [batch, 3, 256, 256], output logits [batch, 2]. fp16: onnxruntime.transformers.float16.convert_float_to_float16(keep_io_types=True). uint8: onnxruntime.quantization.quantize_dynamic(op_types_to_quantize=['MatMul'], weight_type=QUInt8).

Use

transformers.js has no SwinV2 class, so load it with AutoModel (base-class fallback) and preprocess yourself: resize to 256 x 256 (no crop, bicubic or the browser's high-quality resize), scale to 0..1, normalise with ImageNet mean [0.485, 0.456, 0.406] and std [0.229, 0.224, 0.225]. Softmax over the logits; index 0 is artificial, index 1 is real.

import { AutoModel, Tensor } from '@huggingface/transformers';
const model = await AutoModel.from_pretrained('SoldadoXara/ai-image-detector-deploy-ONNX', { dtype: 'fp16', device: 'webgpu' });
const { logits } = await model({ pixel_values: new Tensor('float32', chw, [1, 3, 256, 256]) });

Licence

Apache 2.0, as the original model. This repository only redistributes a converted copy.

Downloads last month
733
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for SoldadoXara/ai-image-detector-deploy-ONNX

Unable to build the model tree, the base model loops to the model itself. Learn more.