Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”¨ Added Tests for POT and NNCF Compression Types #2438

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions tests/integration/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import torch

from anomalib.cli import AnomalibCLI
from anomalib.deploy import ExportType
from anomalib.deploy import CompressionType, ExportType


class TestCLI:
Expand Down Expand Up @@ -155,29 +155,41 @@ def test_predict_with_image_path(self, project_path: Path) -> None:
)
torch.cuda.empty_cache()

@pytest.mark.parametrize("export_type", [ExportType.TORCH, ExportType.ONNX, ExportType.OPENVINO])
@pytest.mark.parametrize(
("export_type", "compression_type"),
[
(ExportType.TORCH, None),
(ExportType.ONNX, None),
(ExportType.OPENVINO, None),
(ExportType.OPENVINO, CompressionType.POT),
(ExportType.OPENVINO, CompressionType.NNCF),
sky0walker99 marked this conversation as resolved.
Show resolved Hide resolved
],
)
def test_export(
self,
project_path: Path,
export_type: ExportType,
compression_type: CompressionType | None,
) -> None:
"""Test the export method of the CLI.

Args:
dataset_path (Path): Root of the synthetic/original dataset.
project_path (Path): Path to temporary project folder.
export_type (ExportType): Export type.
compression_type (CompressionType): Compression type (if any).
"""
AnomalibCLI(
args=[
"export",
"--export_type",
export_type,
*self._get_common_cli_args(None, project_path),
"--ckpt_path",
f"{project_path}/Padim/MVTec/dummy/v0/weights/lightning/model.ckpt",
],
)
args = [
"export",
"--export_type",
export_type,
*self._get_common_cli_args(None, project_path),
"--ckpt_path",
f"{project_path}/Padim/MVTec/dummy/v0/weights/lightning/model.ckpt",
]
if compression_type:
args += ["--compression_type", str(compression_type)]
AnomalibCLI(args=args)

@staticmethod
def _get_common_cli_args(dataset_path: Path | None, project_path: Path) -> list[str]:
Expand Down
Loading