


import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding



class 						_UpperCAmelCase      (     lowercase							):
		lowerCamelCase_	:			List[Any]       			=  ["""image_processor""", """tokenizer"""]
		lowerCamelCase_	:			List[Any]       			=  """ChineseCLIPImageProcessor"""
		lowerCamelCase_	:			List[str]       			=  ("""BertTokenizer""", """BertTokenizerFast""")






		def __init__(						self				:     int   ,  UpperCAmelCase				:     List[str]=None   ,  UpperCAmelCase				:     List[Any]=None   ,  **UpperCAmelCase				:     Dict):
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						None
				if "feature_extractor" in kwargs:
						warnings.warn(
						    "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
						    " instead."   ,  UpperCAmelCase   ,  )
						SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						kwargs.pop("feature_extractor")

				SCREAMING_SNAKE_CASE_				:int				     =						image_processor if image_processor is not None else feature_extractor
				if image_processor is None:
						raise ValueError("You need to specify an `image_processor`.")
				if tokenizer is None:
						raise ValueError("You need to specify a `tokenizer`.")

				super().__init__(UpperCAmelCase   ,  UpperCAmelCase)
				SCREAMING_SNAKE_CASE_				:str				     =						self.image_processor






		def __call__(						self				:     List[str]   ,  UpperCAmelCase				:     Optional[int]=None   ,  UpperCAmelCase				:     List[str]=None   ,  UpperCAmelCase				:     str=None   ,  **UpperCAmelCase				:     Union[str, Any]):

				if text is None and images is None:
						raise ValueError("You have to specify either text or images. Both cannot be none.")

				if text is not None:
						SCREAMING_SNAKE_CASE_				:int				     =						self.tokenizer(UpperCAmelCase   ,  return_tensors=UpperCAmelCase   ,  **UpperCAmelCase)

				if images is not None:
						SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						self.image_processor(UpperCAmelCase   ,  return_tensors=UpperCAmelCase   ,  **UpperCAmelCase)

				if text is not None and images is not None:
						SCREAMING_SNAKE_CASE_				:Dict				     =						image_features.pixel_values
						return encoding
				elif text is not None:
						return encoding
				else:
						return BatchEncoding(data=dict(**UpperCAmelCase)   ,  tensor_type=UpperCAmelCase)






		def _snake_case		(						self				:     int   ,  *UpperCAmelCase				:     Dict   ,  **UpperCAmelCase				:     Optional[int]):
				return self.tokenizer.batch_decode(*UpperCAmelCase   ,  **UpperCAmelCase)






		def _snake_case		(						self				:     str   ,  *UpperCAmelCase				:     Dict   ,  **UpperCAmelCase				:     Dict):
				return self.tokenizer.decode(*UpperCAmelCase   ,  **UpperCAmelCase)






		@property
		def _snake_case		(						self				:     List[Any]):
				SCREAMING_SNAKE_CASE_				:str				     =						self.tokenizer.model_input_names
				SCREAMING_SNAKE_CASE_				:Optional[int]				     =						self.image_processor.model_input_names
				return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))







		@property
		def _snake_case		(						self				:     Union[str, Any]):
				warnings.warn(
				    "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."   ,  UpperCAmelCase   ,  )
				return self.image_processor_class










from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
    is_vision_available,
)


SCREAMING_SNAKE_CASE__     					=			{
    "configuration_owlvit": [
        "OWLVIT_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "OwlViTConfig",
        "OwlViTOnnxConfig",
        "OwlViTTextConfig",
        "OwlViTVisionConfig",
    ],
    "processing_owlvit": ["OwlViTProcessor"],
}


try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		SCREAMING_SNAKE_CASE__     					=			["OwlViTFeatureExtractor"]
		SCREAMING_SNAKE_CASE__     					=			["OwlViTImageProcessor"]

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		SCREAMING_SNAKE_CASE__     					=			[
		    "OWLVIT_PRETRAINED_MODEL_ARCHIVE_LIST",
		    "OwlViTModel",
		    "OwlViTPreTrainedModel",
		    "OwlViTTextModel",
		    "OwlViTVisionModel",
		    "OwlViTForObjectDetection",
		]

if TYPE_CHECKING:
		from .configuration_owlvit import (
		    OWLVIT_PRETRAINED_CONFIG_ARCHIVE_MAP,
		    OwlViTConfig,
		    OwlViTOnnxConfig,
		    OwlViTTextConfig,
		    OwlViTVisionConfig,
		)
		from .processing_owlvit import OwlViTProcessor

		try:
				if not is_vision_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_owlvit import OwlViTFeatureExtractor
				from .image_processing_owlvit import OwlViTImageProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_owlvit import (
				    OWLVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    OwlViTForObjectDetection,
				    OwlViTModel,
				    OwlViTPreTrainedModel,
				    OwlViTTextModel,
				    OwlViTVisionModel,
				)

else:
		import sys

		SCREAMING_SNAKE_CASE__     					=			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)






