Unofficial pytorch dataset class for MVTec Anomaly Detection Dataset
- torchvision
$ python setup.py install
- download MVTecAD data from the official site.
- unzip tar ball in
./data/
.
$ tar xJvf mvtec_anomaly_detection.tar.xz
$ rm mvtec_anomaly_detection.tar.xz
$ ls data/
bottle cable capsule carpet grid hazelnut leather license.txt metal_nut pill readme.txt screw tile toothbrush transistor wood zipper
- run the following script to ensure installation complete collectly.
from torchvision import transforms
from mvtecad_pytorch.dataset import MVTecADDataset
_transforms = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor()])
dataset = MVTecADDataset(root="./data", target="capsule", transforms=_transforms, mask_transforms=_transforms, train=False)
for i in range(len(dataset)):
img, mask, label = dataset[i]
print(img.shape, mask.shape, label)
- use the dataset in your anomaly detection code!