DFR MVTec AD f{1:12} checkpoints
本仓库保存 DFR 在 MVTec AD 全部15个 类别上的复现权重。每个类别独立训练一个 CAE,均训练700 epochs。
这些是 VGG19 前12个卷积特征层的 f{1:12} 权重,不是
f{1:16} 权重。
复现代码、运行说明和精选异常图位于 sun-cn-pirate/DFR-8-16。
Paper-aligned results
原论文采用的正式评价指标是像素级 ROC-AUC 和 PRO-AUC(积分到30% FPR)。
| Configuration | Pixel ROC-AUC | PRO-AUC |
|---|---|---|
This reproduction, f{1:12} |
0.94746 | 0.89045 |
Paper, f{1:12} |
0.94 | 0.90 |
Paper, f{1:16} |
0.95 | 0.91 |
逐类别结果位于 reports/dfr_mvtec_summary.md。其中其他数值是复现程序输出的
补充诊断量,不属于原论文正式评价指标。
Files
weights/
bottle/
autoencoder.pth
n_dim.npy
...
zipper/
autoencoder.pth
n_dim.npy
reports/
dfr_mvtec_summary.csv
dfr_mvtec_summary.md
environment.json
mvtec_validation.json
manifest.json
SHA256SUMS
每个 autoencoder.pth 是从 epoch 700 完整 checkpoint 中导出的 CAE
state dict,只包含推理需要的模型参数和 BatchNorm buffers。Adam optimizer、
RNG state 和绝对本地路径没有上传;服务器上的原始可续训 checkpoint 保持不变。
15类推理权重合计约1.06 GiB。
n_dim.npy 保存该类别由 PCA 90% 方差确定的 CAE latent dimension。
| Category | Latent dimension |
|---|---|
| bottle | 197 |
| cable | 669 |
| capsule | 262 |
| carpet | 383 |
| grid | 209 |
| hazelnut | 514 |
| leather | 432 |
| metal_nut | 532 |
| pill | 396 |
| screw | 433 |
| tile | 633 |
| toothbrush | 339 |
| transistor | 407 |
| wood | 437 |
| zipper | 128 |
Download
下载整个模型仓库:
hf download sun-cn/DFR-MVTec-AD-f1-12 \
--local-dir DFR-MVTec-AD-f1-12
只下载一个类别:
hf download sun-cn/DFR-MVTec-AD-f1-12 \
--include "weights/bottle/*" \
--local-dir DFR-MVTec-AD-f1-12
Load a CAE
先克隆复现代码,并在项目环境中执行:
from pathlib import Path
import sys
import numpy as np
import torch
sys.path.insert(0, str(Path("DFR-8-16/DFR-source").resolve()))
from feat_cae import FeatCAE
category_dir = Path("DFR-MVTec-AD-f1-12/weights/bottle")
n_dim = int(np.load(category_dir / "n_dim.npy", allow_pickle=False).item())
state_dict = torch.load(
category_dir / "autoencoder.pth",
map_location="cpu",
weights_only=True,
)
in_channels = state_dict["encoder.0.weight"].shape[1]
model = FeatCAE(in_channels=in_channels, latent_dim=n_dim, is_bn=True)
model.load_state_dict(state_dict)
model.eval()
完整推理仍需要复现仓库中的 VGG19 特征提取与区域聚合代码,以及 ImageNet 预训练 VGG19 参数;本模型仓库没有包含 VGG19 权重或 MVTec AD 原始数据。
Reproduction configuration
- Input size: 256 × 256
- Feature extractor: frozen ImageNet-pretrained VGG19
- Feature layers:
relu1_1throughrelu4_4(12 layers) - Feature alignment: nearest-neighbor
- Regional aggregation: 4 × 4 mean filter, stride 4
- Padding in VGG19: reflection padding
- PCA: retain 90% variance, independently per category
- CAE: six 1 × 1 convolution layers with batch normalization
- Optimizer: Adam, learning rate
1e-4 - Batch size: 4
- Epochs: 700 per category
- Seed: 0
Tested environment: Python 3.12.11, PyTorch 2.13.0+cu132, torchvision 0.28.0+cu132, CUDA 13.2, NVIDIA GeForce RTX 4090.
Data and license notice
The original implementation was imported from
YoungGod/DFR, upstream commit
f2e2d4ef5e542fb99aa41566cd9f662bec9ce771. The upstream repository does
not provide a software LICENSE. These checkpoints are published for
non-commercial research reproduction without claiming permission to relicense
the upstream implementation.
MVTec AD images are not included. Users must obtain the dataset separately and comply with its CC BY-NC-SA 4.0 terms.
Citation
@article{DFR2020,
title = {Unsupervised anomaly segmentation via deep feature reconstruction},
journal = {Neurocomputing},
year = {2020},
doi = {10.1016/j.neucom.2020.11.018},
author = {Yong Shi and Jie Yang and Zhiquan Qi}
}