


import warnings

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







class 	__lowercase    (__SCREAMING_SNAKE_CASE  ):





							"""simple docstring"""







							_UpperCAmelCase      =						["""image_processor""", """tokenizer"""]
							_UpperCAmelCase      =						"""ViTImageProcessor"""
							_UpperCAmelCase      =						("""CLIPTokenizer""", """CLIPTokenizerFast""")






							def __init__(      self			,						lowerCAmelCase__=None			,						lowerCAmelCase__=None			,						**lowerCAmelCase__       ):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_		:     Any					=					None
										if "feature_extractor" in kwargs:
													warnings.warn(
													    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
													    ' instead.'			,						lowerCAmelCase__			,						)
													SCREAMING_SNAKE_CASE_		:     Optional[int]					=					kwargs.pop('feature_extractor'       )

										SCREAMING_SNAKE_CASE_		:     str					=					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__(lowerCAmelCase__			,						lowerCAmelCase__       )






							def __call__(      self			,						lowerCAmelCase__=None			,						lowerCAmelCase__=None			,						lowerCAmelCase__=None			,						lowerCAmelCase__=None			,						**lowerCAmelCase__       ):





										"""simple docstring"""




										if text is None and visual_prompt is None and images is None:
													raise ValueError('You have to specify either text, visual prompt or images.'       )

										if text is not None and visual_prompt is not None:
													raise ValueError('You have to specify exactly one type of prompt. Either text or visual prompt.'       )

										if text is not None:
													SCREAMING_SNAKE_CASE_		:     Optional[int]					=					self.tokenizer(lowerCAmelCase__			,						return_tensors=lowerCAmelCase__			,						**lowerCAmelCase__       )

										if visual_prompt is not None:
													SCREAMING_SNAKE_CASE_		:     int					=					self.image_processor(lowerCAmelCase__			,						return_tensors=lowerCAmelCase__			,						**lowerCAmelCase__       )

										if images is not None:
													SCREAMING_SNAKE_CASE_		:     Dict					=					self.image_processor(lowerCAmelCase__			,						return_tensors=lowerCAmelCase__			,						**lowerCAmelCase__       )

										if visual_prompt is not None and images is not None:
													SCREAMING_SNAKE_CASE_		:     List[str]					=					{
													    'pixel_values': image_features.pixel_values,
													    'conditional_pixel_values': prompt_features.pixel_values,
													}
													return encoding
										elif text is not None and images is not None:
													SCREAMING_SNAKE_CASE_		:     Optional[int]					=					image_features.pixel_values
													return encoding
										elif text is not None:
													return encoding
										elif visual_prompt is not None:
													SCREAMING_SNAKE_CASE_		:     Tuple					=					{
													    'conditional_pixel_values': prompt_features.pixel_values,
													}
													return encoding
										else:
													return BatchEncoding(data=dict(**lowerCAmelCase__       )			,						tensor_type=lowerCAmelCase__       )






							def 					UpperCamelCase__     (      self			,						*lowerCAmelCase__			,						**lowerCAmelCase__       ):





										"""simple docstring"""




										return self.tokenizer.batch_decode(*lowerCAmelCase__			,						**lowerCAmelCase__       )






							def 					UpperCamelCase__     (      self			,						*lowerCAmelCase__			,						**lowerCAmelCase__       ):





										"""simple docstring"""




										return self.tokenizer.decode(*lowerCAmelCase__			,						**lowerCAmelCase__       )






							@property
							def 					UpperCamelCase__     (      self       ):





										"""simple docstring"""




										warnings.warn(
										    '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'			,						lowerCAmelCase__			,						)
										return self.image_processor_class






							@property
							def 					UpperCamelCase__     (      self       ):





										"""simple docstring"""




										warnings.warn(
										    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'			,						lowerCAmelCase__			,						)
										return self.image_processor









from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowerCAmelCase__			:      str								={
    'configuration_clipseg': [
        'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'CLIPSegConfig',
        'CLIPSegTextConfig',
        'CLIPSegVisionConfig',
    ],
    'processing_clipseg': ['CLIPSegProcessor'],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowerCAmelCase__			:      Optional[Any]								=[
				    'CLIPSEG_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'CLIPSegModel',
				    'CLIPSegPreTrainedModel',
				    'CLIPSegTextModel',
				    'CLIPSegVisionModel',
				    'CLIPSegForImageSegmentation',
				]

if TYPE_CHECKING:
				from .configuration_clipseg import (
				    CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP,
				    CLIPSegConfig,
				    CLIPSegTextConfig,
				    CLIPSegVisionConfig,
				)
				from .processing_clipseg import CLIPSegProcessor

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_clipseg import (
								    CLIPSEG_PRETRAINED_MODEL_ARCHIVE_LIST,
								    CLIPSegForImageSegmentation,
								    CLIPSegModel,
								    CLIPSegPreTrainedModel,
								    CLIPSegTextModel,
								    CLIPSegVisionModel,
								)

else:
				import sys

				lowerCAmelCase__			:      str								=_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





