--- license: other tags: - image-classification - ai-generated-image-detection - lorc - dinov3 pipeline_tag: image-classification --- # mLoRC (Modulated-LoRC) An [LoRC](https://arxiv.org/abs/2608.20882) (Low-Rank Collapse) AI-generated-image detector: a frozen **DINOv3 ViT-H+/16** backbone + LoRA adapters, an orthogonal decomposition of the patch tokens against the [CLS] token, and a Low-Rank Attention Block on the residual subspace, fine-tuned on the full [DDA-Training-Set](https://arxiv.org/abs/2608.20882) (118,287 real/fake pairs) with **pair-aware energy augmentation** — a training-time trick that randomly rescales each pair's residual-subspace magnitude (simulating different image compositions/energy bands) while mathematically guaranteeing the real>fake energy ordering *within* every pair is preserved exactly. `attn_rank=64`, LoRA `rank=32/α=32` (folded into the backbone weights below, not shipped as a separate adapter). ## Why pair-aware, not per-sample An earlier version of this augmentation drew an independent random scale for every image, real and fake alike. That let a real image get scaled down while its own paired fake got scaled up in the same batch — a real, quantified risk (23.75% instantaneous real/fake energy-inversion rate per augmented draw, vs. a 3.80% natural baseline). This checkpoint's training draws **one shared scale factor per real/fake pair** instead — proven, not just observed, to leave the inversion rate exactly at the 3.80% baseline, since scaling both sides of a ratio by the same factor can't flip its sign. ## Results (full 30,000-image WildFake eval) | | Clean BAcc | Clean AUC | Full (transformed) BAcc | Full AUC | |---|---|---|---|---| | v2 baseline (no aug) | 95.01% | 0.9911 | 91.92% | 0.9739 | | **mLoRC** | **96.57%** | **0.9929** | **92.65%** | 0.9723 | Biggest gains: real-photo groups that were previously the model's weakest point — celebahq (85.4%→94.7% under transforms), ffhq (84.3%→94.4%). Full per-generator breakdown, throughput benchmarks, and training details: see [Buxt-Codes/AIGI-mLoRC](https://github.com/Buxt-Codes/AIGI-mLoRC) — the code that loads this checkpoint lives there, not in this HF repo. Known regression: Imagen (Google) under transforms, 91.9%→90.9% — the one generator where this trick's real-photo gains don't fully offset a drop in raw recall on that specific generator (93.7%→86.1%). ## Usage Clone [Buxt-Codes/AIGI-mLoRC](https://github.com/Buxt-Codes/AIGI-mLoRC), set up its `requirements.txt`, then: ```python from mlorc import ModulatedLoRC model = ModulatedLoRC.from_pretrained() # pulls mlorc-full.pt from this repo result = model.predict_image("photo.jpg") print(result) # {"label": "fake", "p_fake": 0.93, "p_real": 0.07} ``` or, for a whole directory of images: ```bash python predict.py --input_dir --output results.json ``` This repo is **private** — pass a token (`from_pretrained(hf_token="hf_...")` or set `HF_TOKEN`/run `huggingface-cli login`) to access it. Getting access here is the *only* gate: unlike the base DINOv3 checkpoint (`facebook/dinov3-vith16plus-pretrain-lvd1689m`, gated with **manual review** by Meta), loading this model never touches that repo at all — see `Files`. ## Files - `mlorc-full.pt` (~1.6GB, bf16) — **one self-contained checkpoint**: the DINOv3 ViT-H+/16 backbone with the trained LoRA adapters already folded into its weights (`peft`'s `merge_and_unload()`, verified numerically exact before shipping — max output difference vs. the pre-merge model was 1e-12, pure floating-point noise), plus the Low-Rank Attention Block and classifier head. - `dinov3_config.json` — DINOv3's architecture metadata (hidden size, layer count, etc.) mirrored here, **not its weights**. Together with `mlorc-full.pt` this means loading the model never needs access to `facebook/dinov3-vith16plus-pretrain-lvd1689m` at all — verified with that repo's local cache deliberately removed before loading, output still bit-identical. No adapter file, no second HF repo, no Meta gate to clear.