zobeir commited on
Commit
996a0ce
Β·
verified Β·
1 Parent(s): 198defb

Update README: published DOI, final 224-res CV numbers, fix under-review status

Browse files
Files changed (1) hide show
  1. README.md +43 -26
README.md CHANGED
@@ -17,8 +17,9 @@ language:
17
 
18
  Trained checkpoints for **GoldFormer** and baseline models from the paper:
19
 
20
- > **GoldFormer: A Texture-Aware Vision Transformer-based Algorithm for Detecting Near-Identical Images**
21
- > Z. Raisi, *Algorithms* (MDPI), under review.
 
22
  > Code & dataset: [github.com/zobeirraisi/GoldNet](https://github.com/zobeirraisi/GoldNet)
23
 
24
  ## Task
@@ -27,37 +28,49 @@ Binary image classification β€” **authentic vs. counterfeit gold items** β€” fro
27
 
28
  ## Available Checkpoints (`weights/`)
29
 
30
- | File | Model | Accuracy (5-fold CV) |
31
- |---|---|---|
32
- | `GoldFormer_best.pth` | GoldFormer (CNN + Swin-T + TAAG) | 94.69 Β± 0.79% |
33
- | `Swin_T_best.pth` | Swin Transformer-Tiny | 94.31 Β± 0.78% |
34
- | `ViT_B16_best.pth` | ViT-B/16 | 94.31 Β± 0.94% |
35
- | `ResNet101_best.pth` | ResNet-101 | 92.29 Β± 1.01% |
36
- | `ResNet50_best.pth` | ResNet-50 | β€” |
37
- | `ResNet18_best.pth` | ResNet-18 | β€” |
38
- | `DenseNet121_best.pth` | DenseNet-121 | β€” |
39
- | `EfficientNet_B3_best.pth` | EfficientNet-B3 | β€” |
40
- | `EfficientNet_B0_best.pth` | EfficientNet-B0 | β€” |
41
- | `MobileNet_V2_best.pth` | MobileNet-V2 | β€” |
42
-
43
- All models trained with 5-fold stratified cross-validation, AdamW, AMP (bfloat16), freeze-then-unfreeze fine-tuning on the GoldNet dataset (2,127 images, 1,044 authentic / 1,083 counterfeit).
 
 
 
 
 
 
 
 
 
44
 
45
  ## Usage
46
 
47
  ```python
48
  import torch
49
- from torchvision import transforms
50
- from PIL import Image
51
 
52
  # Download weights
53
  # bash fetch_weights.sh (from the GitHub repo)
54
 
55
- # Load a checkpoint
56
- model = torch.load("weights/GoldFormer_best.pth", weights_only=True)
 
57
  model.eval()
58
 
 
 
 
59
  transform = transforms.Compose([
60
- transforms.Resize((299, 299)),
61
  transforms.ToTensor(),
62
  transforms.Normalize([0.485, 0.456, 0.406],
63
  [0.229, 0.224, 0.225]),
@@ -67,24 +80,28 @@ img = Image.open("your_image.jpg").convert("RGB")
67
  x = transform(img).unsqueeze(0)
68
 
69
  with torch.no_grad():
70
- logits = model(x)
71
  prob_authentic = torch.softmax(logits, dim=1)[0, 0].item()
72
  print(f"P(authentic) = {prob_authentic:.3f}")
73
  ```
74
 
75
- > **Note:** All baseline models use 224Γ—224 input. GoldFormer uses 299Γ—299.
76
- > The `models.py` class definitions are in the [GitHub repo](https://github.com/zobeirraisi/GoldNet).
 
77
 
78
  ## Citation
79
 
80
  ```bibtex
81
  @article{raisi2026goldformer,
82
- title = {GoldFormer: A Texture-Aware Vision Transformer-based Algorithm
83
  for Detecting Near-Identical Images},
84
  author = {Raisi, Zobeir},
85
  journal = {Algorithms},
 
 
 
86
  year = {2026},
87
- note = {Under review}
88
  }
89
  ```
90
 
 
17
 
18
  Trained checkpoints for **GoldFormer** and baseline models from the paper:
19
 
20
+ > **GoldFormer: A Texture-Aware Vision Transformer-Based Algorithm for Detecting Near-Identical Images**
21
+ > Z. Raisi, *Algorithms* (MDPI), 2026, 19(7), 530.
22
+ > DOI: [10.3390/a19070530](https://doi.org/10.3390/a19070530). Open access (CC BY 4.0).
23
  > Code & dataset: [github.com/zobeirraisi/GoldNet](https://github.com/zobeirraisi/GoldNet)
24
 
25
  ## Task
 
28
 
29
  ## Available Checkpoints (`weights/`)
30
 
31
+ Results below are 5-fold stratified cross-validation at matched 224Γ—224 resolution (the paper's primary setting).
32
+
33
+ | File | Model | Accuracy (%) | F1 |
34
+ |---|---|---|---|
35
+ | `GoldFormer_best.pth` | GoldFormer (CNN + Swin-T + TAAG) | **95.02 Β± 0.75** | **0.9502** |
36
+ | `ViT_B16_best.pth` | ViT-B/16 | 94.31 Β± 0.94 | 0.9431 |
37
+ | `Swin_T_best.pth` | Swin Transformer-Tiny (GoldFormer's backbone) | 93.65 Β± 0.67 | 0.9365 |
38
+ | `ResNet101_best.pth` | ResNet-101 | 92.29 Β± 1.01 | 0.9228 |
39
+ | `ResNet50_best.pth` | ResNet-50 | β€” | β€” |
40
+ | `ResNet18_best.pth` | ResNet-18 | β€” | β€” |
41
+ | `DenseNet121_best.pth` | DenseNet-121 | β€” | β€” |
42
+ | `EfficientNet_B3_best.pth` | EfficientNet-B3 | β€” | β€” |
43
+ | `EfficientNet_B0_best.pth` | EfficientNet-B0 | β€” | β€” |
44
+ | `MobileNet_V2_best.pth` | MobileNet-V2 | β€” | β€” |
45
+
46
+ GoldFormer is the best single model and beats a soft-voting ensemble (94.92%); it is
47
+ statistically tied with the strongest individual backbone, ViT-B/16 (paired McNemar
48
+ p = 0.228), and significantly beats its own Swin-T backbone (p = 0.014), while using
49
+ about half ViT-B/16's FLOPs (8.6 vs 16.9 GFLOPs) and fewer parameters (54.3M vs 86.6M).
50
+
51
+ All models trained with 5-fold stratified cross-validation, AdamW, AMP (bfloat16),
52
+ freeze-then-unfreeze fine-tuning on the GoldNet dataset (2,127 images, 1,044
53
+ authentic / 1,083 counterfeit).
54
 
55
  ## Usage
56
 
57
  ```python
58
  import torch
59
+ from models import build_model # models.py from the GitHub repo
 
60
 
61
  # Download weights
62
  # bash fetch_weights.sh (from the GitHub repo)
63
 
64
+ model = build_model("goldformer")
65
+ state = torch.load("weights/GoldFormer_best.pth", map_location="cpu", weights_only=True)
66
+ model.load_state_dict(state) # strict β€” exact match with the released checkpoint
67
  model.eval()
68
 
69
+ from torchvision import transforms
70
+ from PIL import Image
71
+
72
  transform = transforms.Compose([
73
+ transforms.Resize((224, 224)),
74
  transforms.ToTensor(),
75
  transforms.Normalize([0.485, 0.456, 0.406],
76
  [0.229, 0.224, 0.225]),
 
80
  x = transform(img).unsqueeze(0)
81
 
82
  with torch.no_grad():
83
+ logits, gamma = model(x) # gamma = TAAG gate activations, for interpretability
84
  prob_authentic = torch.softmax(logits, dim=1)[0, 0].item()
85
  print(f"P(authentic) = {prob_authentic:.3f}")
86
  ```
87
 
88
+ > **Note:** All checkpoints, including GoldFormer, use 224Γ—224 input in the published
89
+ > configuration. The `models.py` class definitions (`TextureAwareAttentionGate` +
90
+ > `GoldFormer`) are in the [GitHub repo](https://github.com/zobeirraisi/GoldNet).
91
 
92
  ## Citation
93
 
94
  ```bibtex
95
  @article{raisi2026goldformer,
96
+ title = {GoldFormer: A Texture-Aware Vision Transformer-Based Algorithm
97
  for Detecting Near-Identical Images},
98
  author = {Raisi, Zobeir},
99
  journal = {Algorithms},
100
+ volume = {19},
101
+ number = {7},
102
+ pages = {530},
103
  year = {2026},
104
+ doi = {10.3390/a19070530}
105
  }
106
  ```
107