Skip to content

❓ Engine test and predict image size is always 256 x 256 #3012

@prrw

Description

@prrw

Your Question

I am using EfficientAD model and configuring the image size to 512 x 512 using the function configure_pre_processor(). And I think it accepts it well. I found this out by monitoring the GPU memory while training. However the tests using engine.test() after training save the anomaly maps in 768 x 256 consisting of 3 images in one (Normal, Normal+Anomaly, Normal + Predictions). Same behavior is observed in the function engine.predict(). I would like to get each of these images in the form of 512 x 512. Am I missing anything ? Below is my code.

from pathlib import Path
from anomalib.data import Folder
from anomalib.engine import Engine
from anomalib.models import EfficientAd

# 2. Set up a pre-processing configuration
pre_processor = EfficientAd.configure_pre_processor(image_size=(512, 512))

# 3. Custom Configuration
# Configure model parameters
model = EfficientAd(
    pre_processor=pre_processor,
)

# 4. Training Pipeline
# Default structure expects:
# - train/good: Normal (good) training images
# - test/good: Normal test images
# - test/defect: Anomalous test images
datamodule = Folder(
    name="hasse",
    root=Path("./datasets/my_dataset"),
    normal_dir="OK",  # Subfolder containing normal images
    abnormal_dir="NOK",  # Subfolder containing anomalous images
    train_batch_size=1,
)

# Initialize training engine with specific settings
engine = Engine(
    max_epochs=20,
    accelerator="auto",  # Automatically detect GPU/CPU
    devices=1,  # Number of devices to use
)

if __name__ == "__main__":
    # Train the model
    engine.fit(
        model=model,
        datamodule=datamodule,
    )

    # Test the model performance
    test_results = engine.test(
        model=model,
        datamodule=datamodule,
    )

Forum Check

  • I have searched the discussions forum for an answer to my question.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions