File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ dependencies = [
34
34
" jsonargparse[signatures]>=4.27.7" ,
35
35
" docstring_parser" , # CLI help-formatter
36
36
" rich_argparse" , # CLI help-formatter
37
+ " lightning-utilities" ,
37
38
]
38
39
39
40
[project .optional-dependencies ]
@@ -293,11 +294,15 @@ pythonpath = "src"
293
294
# COVERAGE CONFIGURATION #
294
295
[tool .coverage .report ]
295
296
exclude_lines = [
296
- " except ImportError" ,
297
+ " pragma: no cover" ,
298
+ " def __repr__" ,
299
+ " raise NotImplementedError" ,
300
+ " if TYPE_CHECKING:" ,
301
+ " @abstractmethod" ,
302
+ " pass" ,
297
303
" raise ImportError" ,
298
- " except ApiException" ,
299
- " raise ApiException" ,
300
304
" raise ValueError" ,
305
+ " except ImportError:" ,
301
306
]
302
307
303
308
[tool .coverage .paths ]
Original file line number Diff line number Diff line change @@ -58,9 +58,9 @@ class UnknownModelError(ModuleNotFoundError):
58
58
"Rkde" ,
59
59
"Stfpm" ,
60
60
"Uflow" ,
61
- "AiVad" ,
62
61
"VlmAd" ,
63
62
"WinClip" ,
63
+ "AiVad" ,
64
64
]
65
65
66
66
logger = logging .getLogger (__name__ )
Original file line number Diff line number Diff line change 5
5
6
6
import logging
7
7
from pathlib import Path
8
+ from typing import TYPE_CHECKING
8
9
9
10
from lightning_utilities .core .imports import package_available
10
11
from PIL import Image
11
- from transformers .modeling_utils import PreTrainedModel
12
12
13
13
from anomalib .models .image .vlm_ad .utils import Prompt
14
14
15
15
from .base import Backend
16
16
17
- if package_available ("transformers" ):
18
- import transformers
17
+ if TYPE_CHECKING :
19
18
from transformers .modeling_utils import PreTrainedModel
20
19
from transformers .processing_utils import ProcessorMixin
20
+
21
+ if package_available ("transformers" ):
22
+ import transformers
21
23
else :
22
24
transformers = None
23
25
@@ -39,7 +41,7 @@ def __init__(
39
41
self ._model : PreTrainedModel | None = None
40
42
41
43
@property
42
- def processor (self ) -> ProcessorMixin :
44
+ def processor (self ) -> " ProcessorMixin" :
43
45
"""Get the Huggingface processor."""
44
46
if self ._processor is None :
45
47
if transformers is None :
@@ -49,7 +51,7 @@ def processor(self) -> ProcessorMixin:
49
51
return self ._processor
50
52
51
53
@property
52
- def model (self ) -> PreTrainedModel :
54
+ def model (self ) -> " PreTrainedModel" :
53
55
"""Get the Huggingface model."""
54
56
if self ._model is None :
55
57
if transformers is None :
You can’t perform that action at this time.
0 commit comments