buxtcodes commited on
Commit
9477e06
Β·
verified Β·
1 Parent(s): 653da7a

Strip model card to minimal -- full docs live in the GitHub repo

Browse files
Files changed (1) hide show
  1. README.md +7 -75
README.md CHANGED
@@ -3,90 +3,22 @@ license: other
3
  tags:
4
  - image-classification
5
  - ai-generated-image-detection
6
- - lorc
7
  - dinov3
8
  pipeline_tag: image-classification
9
  ---
10
 
11
- # mLoRC (Modulated-LoRC)
12
 
13
- An [LoRC](https://arxiv.org/abs/2608.20882) (Low-Rank Collapse) AI-generated-image
14
- detector: a frozen **DINOv3 ViT-H+/16** backbone + LoRA adapters, an orthogonal
15
- decomposition of the patch tokens against the [CLS] token, and a Low-Rank
16
- Attention Block on the residual subspace, fine-tuned on the full
17
- [DDA-Training-Set](https://arxiv.org/abs/2608.20882) (118,287 real/fake
18
- pairs) with **pair-aware energy augmentation** β€” a training-time trick that
19
- randomly rescales each pair's residual-subspace magnitude (simulating
20
- different image compositions/energy bands) while mathematically guaranteeing
21
- the real>fake energy ordering *within* every pair is preserved exactly.
22
-
23
- `attn_rank=64`, LoRA `rank=32/Ξ±=32` (folded into the backbone weights below,
24
- not shipped as a separate adapter).
25
-
26
- ## Why pair-aware, not per-sample
27
-
28
- An earlier version of this augmentation drew an independent random scale for
29
- every image, real and fake alike. That let a real image get scaled down
30
- while its own paired fake got scaled up in the same batch β€” a real,
31
- quantified risk (23.75% instantaneous real/fake energy-inversion rate per
32
- augmented draw, vs. a 3.80% natural baseline). This checkpoint's training
33
- draws **one shared scale factor per real/fake pair** instead β€” proven, not
34
- just observed, to leave the inversion rate exactly at the 3.80% baseline,
35
- since scaling both sides of a ratio by the same factor can't flip its sign.
36
-
37
- ## Results (full 30,000-image WildFake eval)
38
-
39
- | | Clean BAcc | Clean AUC | Full (transformed) BAcc | Full AUC |
40
- |---|---|---|---|---|
41
- | v2 baseline (no aug) | 95.01% | 0.9911 | 91.92% | 0.9739 |
42
- | **mLoRC** | **96.57%** | **0.9929** | **92.65%** | 0.9723 |
43
-
44
- Biggest gains: real-photo groups that were previously the model's weakest
45
- point β€” celebahq (85.4%β†’94.7% under transforms), ffhq (84.3%β†’94.4%). Full
46
- per-generator breakdown, throughput benchmarks, and training details: see
47
- [Buxt-Codes/AIGI-mLoRC](https://github.com/Buxt-Codes/AIGI-mLoRC) β€” the code
48
- that loads this checkpoint lives there, not in this HF repo.
49
-
50
- Known regression: Imagen (Google) under transforms, 91.9%β†’90.9% β€” the one
51
- generator where this trick's real-photo gains don't fully offset a drop in
52
- raw recall on that specific generator (93.7%β†’86.1%).
53
-
54
- ## Usage
55
-
56
- Clone [Buxt-Codes/AIGI-mLoRC](https://github.com/Buxt-Codes/AIGI-mLoRC), set
57
- up its `requirements.txt`, then:
58
 
59
  ```python
60
  from mlorc import ModulatedLoRC
61
-
62
- model = ModulatedLoRC.from_pretrained() # pulls mlorc-full.pt from this repo
63
- result = model.predict_image("photo.jpg")
64
- print(result) # {"label": "fake", "p_fake": 0.93, "p_real": 0.07}
65
  ```
66
 
67
- or, for a whole directory of images:
68
-
69
- ```bash
70
- python predict.py --input_dir <path/to/images> --output results.json
71
- ```
72
-
73
- This repo is **private** β€” pass a token (`from_pretrained(hf_token="hf_...")`
74
- or set `HF_TOKEN`/run `huggingface-cli login`) to access it. Getting access
75
- here is the *only* gate: unlike the base DINOv3 checkpoint
76
- (`facebook/dinov3-vith16plus-pretrain-lvd1689m`, gated with **manual review**
77
- by Meta), loading this model never touches that repo at all β€” see `Files`.
78
-
79
  ## Files
80
 
81
- - `mlorc-full.pt` (~1.6GB, bf16) β€” **one self-contained checkpoint**: the
82
- DINOv3 ViT-H+/16 backbone with the trained LoRA adapters already folded
83
- into its weights (`peft`'s `merge_and_unload()`, verified numerically
84
- exact before shipping β€” max output difference vs. the pre-merge model was
85
- 1e-12, pure floating-point noise), plus the Low-Rank Attention Block and
86
- classifier head.
87
- - `dinov3_config.json` β€” DINOv3's architecture metadata (hidden size, layer
88
- count, etc.) mirrored here, **not its weights**. Together with
89
- `mlorc-full.pt` this means loading the model never needs access to
90
- `facebook/dinov3-vith16plus-pretrain-lvd1689m` at all β€” verified with that
91
- repo's local cache deliberately removed before loading, output still
92
- bit-identical. No adapter file, no second HF repo, no Meta gate to clear.
 
3
  tags:
4
  - image-classification
5
  - ai-generated-image-detection
 
6
  - dinov3
7
  pipeline_tag: image-classification
8
  ---
9
 
10
+ # mLoRC
11
 
12
+ AI-generated-image detector (DINOv3 ViT-H+/16 + [LoRC](https://arxiv.org/abs/2608.20882)).
13
+ Code, results, and docs: [Buxt-Codes/AIGI-mLoRC](https://github.com/Buxt-Codes/AIGI-mLoRC).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  ```python
16
  from mlorc import ModulatedLoRC
17
+ model = ModulatedLoRC.from_pretrained(hf_token="hf_...")
18
+ model.predict_image("photo.jpg")
 
 
19
  ```
20
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ## Files
22
 
23
+ - `mlorc-full.pt` β€” full checkpoint, LoRA merged into the backbone weights.
24
+ - `dinov3_config.json` β€” DINOv3 architecture config (no weights).