From ed02bbd1a297fd7897f7051993bfd4d4a999cb9a Mon Sep 17 00:00:00 2001 From: "Kang, Harim" Date: Tue, 5 Nov 2024 16:04:16 +0900 Subject: [PATCH 1/2] VlmAd relies on the python-dotenv package. This is checked separately in the import. Signed-off-by: Kang, Harim --- src/anomalib/models/__init__.py | 9 +++++++-- src/anomalib/models/image/__init__.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/anomalib/models/__init__.py b/src/anomalib/models/__init__.py index 3b32c83367..50e991327c 100644 --- a/src/anomalib/models/__init__.py +++ b/src/anomalib/models/__init__.py @@ -7,6 +7,7 @@ from importlib import import_module from jsonargparse import Namespace +from lightning_utilities.core.imports import module_available from omegaconf import DictConfig, OmegaConf from anomalib.models.components import AnomalyModule @@ -30,7 +31,6 @@ Rkde, Stfpm, Uflow, - VlmAd, WinClip, ) from .video import AiVad @@ -58,11 +58,16 @@ class UnknownModelError(ModuleNotFoundError): "Rkde", "Stfpm", "Uflow", - "VlmAd", "WinClip", "AiVad", ] +if module_available("anomalib.models.image.vlm_ad"): + from .image import VlmAd + + __all__.append("VlmAd") + + logger = logging.getLogger(__name__) diff --git a/src/anomalib/models/image/__init__.py b/src/anomalib/models/image/__init__.py index b09da8b07b..c3069379ba 100644 --- a/src/anomalib/models/image/__init__.py +++ b/src/anomalib/models/image/__init__.py @@ -3,6 +3,8 @@ # Copyright (C) 2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +from lightning_utilities.core.imports import module_available + from .cfa import Cfa from .cflow import Cflow from .csflow import Csflow @@ -20,7 +22,6 @@ from .rkde import Rkde from .stfpm import Stfpm from .uflow import Uflow -from .vlm_ad import VlmAd from .winclip import WinClip __all__ = [ @@ -41,6 +42,11 @@ "Rkde", "Stfpm", "Uflow", - "VlmAd", "WinClip", + "VlmAd", ] + +if module_available("anomalib.models.image.vlm_ad"): + from .vlm_ad import VlmAd + + __all__.append("VlmAd") From d701f4b5304ada908188d8b5a72f9293159026c1 Mon Sep 17 00:00:00 2001 From: "Kang, Harim" Date: Tue, 5 Nov 2024 16:11:30 +0900 Subject: [PATCH 2/2] Fix wrong Signed-off-by: Kang, Harim --- src/anomalib/models/image/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/anomalib/models/image/__init__.py b/src/anomalib/models/image/__init__.py index c3069379ba..a585d93cb1 100644 --- a/src/anomalib/models/image/__init__.py +++ b/src/anomalib/models/image/__init__.py @@ -43,7 +43,6 @@ "Stfpm", "Uflow", "WinClip", - "VlmAd", ] if module_available("anomalib.models.image.vlm_ad"):