❓ <title>Can you please tell me the specific training parameters that are officially used to train the MVTecAD dataset using patchcore? #3247
-
Your QuestionCan you please tell me the specific training parameters that are officially used to train the MVTecAD dataset using patchcore? The results I get when I use this code to train are way off compared to the official results, Patchcore Results. I would like to know what is the reason for this? from anomalib.data import MVTecAD
from anomalib.engine import Engine
from anomalib.models import Patchcore
from pathlib import Path
from anomalib.data import Folder
# 1. Basic Usage
# Initialize with default settings
model = Patchcore()
# 2. Custom Configuration
# Configure model parameters
model = Patchcore(
backbone="wide_resnet50_2", # Feature extraction backbone
layers=["layer2", "layer3"], # Layers to extract features from
pre_trained=True, # Use pretrained weights
num_neighbors=9, # Number of nearest neighbors
)
# 3. Training Pipeline
datamodule = MVTecAD(
root="anomalib/datasets/MVTec",
category="bottle",
train_batch_size=16,
eval_batch_size=16, # Important for feature extraction
num_workers=0, # Number of workers for data loading
seed=42,
)
# Initialize training engine with specific settings
engine = Engine(
max_epochs=1, # Patchcore typically needs only one epoch
accelerator="auto", # Automatically detect GPU/CPU
devices=1, # Number of devices to use
)
# Train the model
# engine.fit(
# model=model,
# datamodule=datamodule,
# )
engine.train(
model=model,
datamodule=datamodule,
)┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Test metric ┃ DataLoader 0 ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ image_AUROC │ 1.0 │
│ image_F1Score │ 0.9919999837875366 │
│ pixel_AUROC │ 0.9855615496635437 │
│ pixel_F1Score │ 0.7266571521759033 │
└───────────────────────────┴───────────────────────────┘Forum Check
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
Thanks for submitting this issue! It has been added to our triage queue. A maintainer will review it shortly. |
Beta Was this translation helpful? Give feedback.
-
|
Hey, your results are not really off of these https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/models/image/patchcore/README.md#mvtec-ad-dataset Only your Image F1 is 0.9919999837875366 compared to 1.0 but I wouldn't call it way off |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your reply! I have one more question, I want to ask you, |
Beta Was this translation helpful? Give feedback.
-
|
Thats probably because with the folder dataset, you are only testing on one type of defects |
Beta Was this translation helpful? Give feedback.
Hey, your results are not really off of these https://github.com/open-edge-platform/anomalib/blob/main/src/anomalib/models/image/patchcore/README.md#mvtec-ad-dataset
Only your Image F1 is 0.9919999837875366 compared to 1.0 but I wouldn't call it way off