-
# 1. Import required modules
from anomalib.data import MVTecAD
from anomalib.engine import Engine
from anomalib.models import EfficientAd
# 2. Create a dataset
# MVTecAD is a popular dataset for anomaly detection
datamodule = MVTecAD(
root="./datasets/MVTecAD", # Path to download/store the dataset
category="bottle", # MVTec category to use
train_batch_size=32, # Number of images per training batch
eval_batch_size=32, # Number of images per validation/test batch
num_workers=8, # Number of parallel processes for data loading
)
# 3. Initialize the model
# EfficientAd is a good default choice for beginners
model = EfficientAd()
# 4. Create the training engine
engine = Engine(max_epochs=10) # Train for 10 epochs
# 5. Train the model
engine.fit(datamodule=datamodule, model=model)
|
Beta Was this translation helpful? Give feedback.
Answered by
abc-125
May 24, 2025
Replies: 1 comment
-
Hello, I think this should work in step 3: image_size = (512, 512)
pre_processor = EfficientAd.configure_pre_processor(image_size=image_size)
model = EfficientAd(pre_processor=pre_processor) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
samet-akcay
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I think this should work in step 3: