Skip to content

Commit

Permalink
Add type checking
Browse files Browse the repository at this point in the history
Signed-off-by: Samet Akcay <samet.akcay@intel.com>
  • Loading branch information
samet-akcay committed Oct 24, 2024
1 parent 16f05d5 commit b2bc08b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/anomalib/models/image/vlm_ad/backends/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@

import logging
from pathlib import Path
from typing import TYPE_CHECKING

from lightning_utilities.core.imports import package_available
from PIL import Image
from transformers.modeling_utils import PreTrainedModel

from anomalib.models.image.vlm_ad.utils import Prompt

from .base import Backend

if package_available("transformers"):
import transformers
if TYPE_CHECKING:
from transformers.modeling_utils import PreTrainedModel
from transformers.processing_utils import ProcessorMixin

if package_available("transformers"):
import transformers
else:
transformers = None

Expand All @@ -39,7 +41,7 @@ def __init__(
self._model: PreTrainedModel | None = None

@property
def processor(self) -> ProcessorMixin:
def processor(self) -> "ProcessorMixin":
"""Get the Huggingface processor."""
if self._processor is None:
if transformers is None:
Expand All @@ -49,7 +51,7 @@ def processor(self) -> ProcessorMixin:
return self._processor

@property
def model(self) -> PreTrainedModel:
def model(self) -> "PreTrainedModel":
"""Get the Huggingface model."""
if self._model is None:
if transformers is None:
Expand Down

0 comments on commit b2bc08b

Please sign in to comment.