Skip to content

Commit

Permalink
fix pil import in VLM (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored Nov 22, 2024
1 parent 080180b commit cf5b951
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions optimum/intel/openvino/modeling_visual_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import warnings
from abc import abstractmethod
from pathlib import Path
from typing import Dict, Optional, Tuple, Union
from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union

import numpy as np
import openvino as ov
import torch
from huggingface_hub import hf_hub_download
from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE
from openvino._offline_transformations import apply_moc_transformations, compress_model_transformation
from PIL.Image import Image
from transformers import (
AutoConfig,
AutoImageProcessor,
Expand Down Expand Up @@ -50,6 +49,10 @@
LlavaNextForConditionalGeneration = None


if TYPE_CHECKING:
from PIL import Image


logger = logging.getLogger(__name__)

core = ov.Core()
Expand Down Expand Up @@ -790,7 +793,7 @@ def can_generate(self):
@abstractmethod
def preprocess_inputs(
text: str,
image: Optional[Image] = None,
image: Optional["Image"] = None,
processor: Optional[AutoImageProcessor] = None,
tokenizer: Optional[PreTrainedTokenizer] = None,
config: Optional[PretrainedConfig] = None,
Expand Down Expand Up @@ -967,7 +970,7 @@ def _filter_unattended_tokens(self, input_ids, attention_mask, past_key_values):
@staticmethod
def preprocess_inputs(
text: str,
image: Optional[Image] = None,
image: Optional["Image"] = None,
processor: Optional[AutoImageProcessor] = None,
tokenizer: Optional[PreTrainedTokenizer] = None,
config: Optional[PretrainedConfig] = None,
Expand Down Expand Up @@ -1287,7 +1290,7 @@ def merge_vision_text_embeddings(
@staticmethod
def preprocess_inputs(
text: str,
image: Optional[Image] = None,
image: Optional["Image"] = None,
processor: Optional[AutoImageProcessor] = None,
tokenizer: Optional[PreTrainedTokenizer] = None,
config: Optional[PretrainedConfig] = None,
Expand Down Expand Up @@ -1662,7 +1665,7 @@ def merge_vision_text_embeddings(
@staticmethod
def preprocess_inputs(
text: str,
image: Optional[Image] = None,
image: Optional["Image"] = None,
processor: Optional[AutoImageProcessor] = None,
tokenizer: Optional[PreTrainedTokenizer] = None,
config: Optional[PretrainedConfig] = None,
Expand Down Expand Up @@ -1857,7 +1860,7 @@ def get_multimodal_embeddings(
@staticmethod
def preprocess_inputs(
text: str,
image: Optional[Image] = None,
image: Optional["Image"] = None,
processor: Optional[AutoImageProcessor] = None,
tokenizer: Optional[PreTrainedTokenizer] = None,
config: Optional[PretrainedConfig] = None,
Expand Down Expand Up @@ -2017,7 +2020,7 @@ def get_multimodal_embeddings(
@staticmethod
def preprocess_inputs(
text: str,
image: Optional[Image] = None,
image: Optional["Image"] = None,
processor: Optional[AutoImageProcessor] = None,
tokenizer: Optional[PreTrainedTokenizer] = None,
config: Optional[PretrainedConfig] = None,
Expand Down

0 comments on commit cf5b951

Please sign in to comment.