buxtcodes commited on
Commit
4412238
Β·
verified Β·
1 Parent(s): 773cc88

Update model card for the single merged checkpoint

Browse files
Files changed (1) hide show
  1. README.md +20 -18
README.md CHANGED
@@ -5,11 +5,10 @@ tags:
5
  - ai-generated-image-detection
6
  - lorc
7
  - dinov3
8
- - lora
9
  pipeline_tag: image-classification
10
  ---
11
 
12
- # Modulated-LoRC
13
 
14
  An [LoRC](https://arxiv.org/abs/2608.20882) (Low-Rank Collapse) AI-generated-image
15
  detector: a frozen **DINOv3 ViT-H+/16** backbone + LoRA adapters, an orthogonal
@@ -21,7 +20,8 @@ randomly rescales each pair's residual-subspace magnitude (simulating
21
  different image compositions/energy bands) while mathematically guaranteeing
22
  the real>fake energy ordering *within* every pair is preserved exactly.
23
 
24
- This is "run 1": `attn_rank=64`, `lora_rank=32`.
 
25
 
26
  ## Why pair-aware, not per-sample
27
 
@@ -39,13 +39,13 @@ since scaling both sides of a ratio by the same factor can't flip its sign.
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
- | **This checkpoint** | **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
- `MODULATED_LORC_RUN1_REPORT.md` in the companion GitHub-style repo directory
48
- (`modulated_lorc_inference/`).
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
@@ -53,22 +53,21 @@ raw recall on that specific generator (93.7%β†’86.1%).
53
 
54
  ## Usage
55
 
56
- ```bash
57
- pip install -r requirements.txt # torch, transformers, peft, huggingface_hub, Pillow
58
- ```
59
 
60
  ```python
61
- from inference import ModulatedLoRC
62
 
63
- model = ModulatedLoRC.from_pretrained() # pulls modulated-lorc.pt from this repo
64
  result = model.predict_image("photo.jpg")
65
  print(result) # {"label": "fake", "p_fake": 0.93, "p_real": 0.07}
66
  ```
67
 
68
- or from the command line:
69
 
70
  ```bash
71
- python inference.py photo.jpg
72
  ```
73
 
74
  This repo is **private** β€” pass a token (`from_pretrained(hf_token="hf_...")`
@@ -76,8 +75,11 @@ or set `HF_TOKEN`/run `huggingface-cli login`) to access it.
76
 
77
  ## Files
78
 
79
- - `modulated-lorc.pt` β€” the checkpoint. **Partial save**: only the trained
80
- LoRA adapters (q/k/v/o_proj, rank=32/Ξ±=32), the Low-Rank Attention Block
81
- (rank=64), and the classifier head (~124MB total). The frozen DINOv3
82
- backbone is not included here β€” it's pulled fresh from
83
- `facebook/dinov3-vith16plus-pretrain-lvd1689m` on first load.
 
 
 
 
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
 
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
 
 
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
 
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 modulated_lorc 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_...")`
 
75
 
76
  ## Files
77
 
78
+ - `mlorc-full.pt` (~1.6GB, bf16) β€” **one self-contained checkpoint**: the
79
+ DINOv3 ViT-H+/16 backbone with the trained LoRA adapters already folded
80
+ into its weights (`peft`'s `merge_and_unload()`, verified numerically
81
+ exact before shipping β€” max output difference vs. the pre-merge model was
82
+ 1e-12, pure floating-point noise), plus the Low-Rank Attention Block and
83
+ classifier head. Nothing else needs downloading from anywhere else to run
84
+ this model β€” no separate adapter file, no separate backbone-weights
85
+ download from another HF repo.