Views
No views yet
GoldFormer: A Texture-Aware Vision Transformer-Based Algorithm for Detecting Near-Identical Images
Z. Raisi, Algorithms (MDPI), 2026, 19(7), 530.
DOI: 10.3390/a19070530. Open access (CC BY 4.0).
Code & dataset: github.com/zobeirraisi/GoldNet
weights/)| File | Model | Accuracy (%) | F1 |
|---|---|---|---|
GoldFormer_best.pth | GoldFormer (CNN + Swin-T + TAAG) | 95.02 ± 0.75 | 0.9502 |
ViT_B16_best.pth | ViT-B/16 | 94.31 ± 0.94 | 0.9431 |
Swin_T_best.pth | Swin Transformer-Tiny (GoldFormer's backbone) | 93.65 ± 0.67 | 0.9365 |
ResNet101_best.pth | ResNet-101 | 92.29 ± 1.01 | 0.9228 |
ResNet50_best.pth | ResNet-50 | — | — |
ResNet18_best.pth | ResNet-18 | — | — |
DenseNet121_best.pth | DenseNet-121 | — | — |
EfficientNet_B3_best.pth | EfficientNet-B3 | — | — |
EfficientNet_B0_best.pth | EfficientNet-B0 | — | — |
MobileNet_V2_best.pth | MobileNet-V2 | — | — |
1import torch
2from models import build_model # models.py from the GitHub repo
3
4# Download weights
5# bash fetch_weights.sh (from the GitHub repo)
6
7model = build_model("goldformer")
8state = torch.load("weights/GoldFormer_best.pth", map_location="cpu", weights_only=True)
9model.load_state_dict(state) # strict — exact match with the released checkpoint
10model.eval()
11
12from torchvision import transforms
13from PIL import Image
14
15transform = transforms.Compose([
16 transforms.Resize((224, 224)),
17 transforms.ToTensor(),
18 transforms.Normalize([0.485, 0.456, 0.406],
19 [0.229, 0.224, 0.225]),
20])
21
22img = Image.open("your_image.jpg").convert("RGB")
23x = transform(img).unsqueeze(0)
24
25with torch.no_grad():
26 logits, gamma = model(x) # gamma = TAAG gate activations, for interpretability
27 prob_authentic = torch.softmax(logits, dim=1)[0, 0].item()
28 print(f"P(authentic) = {prob_authentic:.3f}")Note: All checkpoints, including GoldFormer, use 224×224 input in the published configuration. Themodels.pyclass definitions (TextureAwareAttentionGate+GoldFormer) are in the GitHub repo.
1@article{raisi2026goldformer,
2 title = {GoldFormer: A Texture-Aware Vision Transformer-Based Algorithm
3 for Detecting Near-Identical Images},
4 author = {Raisi, Zobeir},
5 journal = {Algorithms},
6 volume = {19},
7 number = {7},
8 pages = {530},
9 year = {2026},
10 doi = {10.3390/a19070530}
11}