openvinotoolkit / anomalib

An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.

Home Page:https://anomalib.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: setting max_epochs when engine instantiation not works

shanmugamani1023 opened this issue · comments

Describe the bug

i tried to create model using custom dataset ,so ,
i used following code

Import the datamodule

from anomalib.data import Folder
from anomalib.data.utils import TestSplitMode

Create the datamodule

datamodule = Folder(
name="bottle",
root="datasets/bottle",
normal_dir="good",
test_split_mode=TestSplitMode.SYNTHETIC,
task="classification",
image_size=(512,512)
)

Setup the datamodule

datamodule.setup(),

after that # Import the model and engine
from anomalib.models import Patchcore
from anomalib.engine import Engine

Create the model and engine

model = Patchcore()
engine = Engine(task="classification",
accelerator="auto",
check_val_every_n_epoch=1,
max_epochs=2,
num_sanity_val_steps=0,
val_check_interval=1.0)
,i configured train arguments like this,
i gave max_epochs=2,
but it only run 1 time ?? how to resolve this issue ?
1_time

Dataset

Other (please specify in the text field below)

Model

PatchCore

Steps to reproduce the behavior

i tried to create model using custom dataset ,so ,
i used following code

Import the datamodule

from anomalib.data import Folder
from anomalib.data.utils import TestSplitMode

Create the datamodule

datamodule = Folder(
name="bottle",
root="datasets/bottle",
normal_dir="good",
test_split_mode=TestSplitMode.SYNTHETIC,
task="classification",
image_size=(512,512)
)

Setup the datamodule

datamodule.setup(),

after that # Import the model and engine
from anomalib.models import Patchcore
from anomalib.engine import Engine

Create the model and engine

model = Patchcore()
engine = Engine(task="classification",
accelerator="auto",
check_val_every_n_epoch=1,
max_epochs=2,
num_sanity_val_steps=0,
val_check_interval=1.0)
,i configured train arguments like this,
i gave max_epochs=2,
but it only run 1 time ?? how to resolve this issue ?
1_time

OS information

OS information:

  • OS: [e.g. Ubuntu 20.04]
  • Python version: [e.g. 3.10.0]
  • Anomalib version: [e.g. 0.3.6]
  • PyTorch version: [e.g. 1.9.0]
  • CUDA/cuDNN version: [e.g. 11.1]
  • GPU models and configuration: [e.g. 2x GeForce RTX 3090]
  • Any other relevant information: [e.g. I'm using a custom dataset]

Expected behavior

need to run 2 times

Screenshots

1_time

Pip/GitHub

pip

What version/branch did you use?

No response

Configuration YAML

null

Logs

null

Code of Conduct

  • I agree to follow this project's Code of Conduct

@shanmugamani1023, Patchcore only needs one epoch to extract the features. Setting more epochs does not help training, which is the reason it is 1 by default and cannot be changed.

For more details, you could refer to the paper
https://arxiv.org/abs/2106.08265

I'm closing this since this is not an issue. Thanks

Thanks, so does every model have its own predefined epochs? Therefore,
Could you please provide me with the epoch values for each model?
Which model allows me to change the epoch number?

You could check them from either model config

or the model implementation

return {"gradient_clip_val": 0, "max_epochs": 1, "num_sanity_val_steps": 0}

Thank you so much, its works fine.