Skip to content

🐞 cli does not allow custom input size #3460

@ashwinvaidya17

Description

@ashwinvaidya17

Describe the bug

With the pre-processor refactor, CLI does not allow setting the image size easily. If one really wants to modify it, they need to recreate the entire pre-processor

anomalib train --model Padim \
  --data MVTecAD \
  --data.category transistor \
  --model.pre_processor anomalib.pre_processing.PreProcessor \
  --model.pre_processor.transform torchvision.transforms.v2.Compose \
  --model.pre_processor.transform.transforms '[torchvision.transforms.v2.Resize([512,512]),torchvision.transforms.v2.Normalize([0.485,0.456,0.406],[0.229,0.224,0.225])]'

Or more practically, use a YAML config file:

model:
  class_path: anomalib.models.Padim
  init_args:
    backbone: resnet18
    pre_processor:
      class_path: anomalib.pre_processing.PreProcessor
      init_args:
        transform:
          class_path: torchvision.transforms.v2.Compose
          init_args:
            transforms:
              - class_path: torchvision.transforms.v2.Resize
                init_args:
                  size: [512, 512]
                  antialias: true
              - class_path: torchvision.transforms.v2.Normalize
                init_args:
                  mean: [0.485, 0.456, 0.406]
                  std: [0.229, 0.224, 0.225]
data:
  class_path: anomalib.data.MVTecAD
  init_args:
    category: transistor

Then run:
anomalib train --config config.yaml

Dataset

N/A

Model

N/A

Steps to reproduce the behavior

N/A

OS information

OS information:

  • Affects all platforms

Expected behavior

Should allow a simple way to update input size

Screenshots

No response

Pip/GitHub

GitHub

What version/branch did you use?

main

Configuration YAML

n/a

Logs

n/a

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions