mirror of
https://github.com/hanzoai/anomalib.git
synced 2026-10-30 18:48:11 +00:00
The previous commit was meant to remove .github/workflows and removed every tracked path instead — 892 files, the whole repo. This puts back the 874 that were never in scope; the eighteen workflow files stay gone, for the reasons that commit gives. Content is byte-identical to 9d2aec9 outside .github/workflows.
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""Test visualizer callback."""
|
|
|
|
# Copyright (C) 2023-2024 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
from anomalib.data import MVTecAD
|
|
from anomalib.engine import Engine
|
|
from anomalib.loggers import AnomalibTensorBoardLogger
|
|
|
|
from .dummy_lightning_model import DummyModule
|
|
|
|
|
|
def test_add_images(dataset_path: Path) -> None:
|
|
"""Tests if tensorboard logs are generated."""
|
|
with tempfile.TemporaryDirectory() as dir_loc:
|
|
logger = AnomalibTensorBoardLogger(name="tensorboard_logs", save_dir=dir_loc)
|
|
model = DummyModule(dataset_path, evaluator=False)
|
|
engine = Engine(
|
|
logger=logger,
|
|
default_root_dir=dir_loc,
|
|
limit_test_batches=1,
|
|
accelerator="cpu",
|
|
)
|
|
engine.test(model=model, datamodule=MVTecAD(root=dataset_path / "mvtecad", category="dummy"))
|
|
# test if images are logged
|
|
assert len(list(Path(dir_loc).glob("**/*.png"))) >= 1, "Failed to save to local path"
|
|
|
|
# test if tensorboard logs are created
|
|
assert len(list((Path(dir_loc) / "tensorboard_logs").glob("version_*"))) != 0, "Failed to save to tensorboard"
|