




'''simple docstring'''





from cva import destroyAllWindows, imread, imshow, waitKey


def 					UpperCamelCase						(	snake_case						,  snake_case ):




   '''simple docstring'''

   SCREAMING_SNAKE_CASE__    ,					SCREAMING_SNAKE_CASE__      :					List[str]							    =			img.shape[0], img.shape[1]

   def to_grayscale(snake_case						,  snake_case						,  snake_case ):
      return 0.2126 * red + 0.587 * green + 0.114 * blue

   def normalize(snake_case ):
      return min(snake_case						,  2_55 )

   for i in range(snake_case ):
      for j in range(snake_case ):
         SCREAMING_SNAKE_CASE__      :					Optional[Any]							    =			int(to_grayscale(*img[i][j] ) )
         SCREAMING_SNAKE_CASE__      :					Union[str, Any]							    =			[
             normalize(snake_case ),
             normalize(greyscale + factor ),
             normalize(greyscale + 2 * factor ),
         ]

   return img


if __name__ == "__main__":
       # read original image
       lowercase__								=						{
           percentage: imread('''image_data/lena.jpg''', 1) for percentage in (1_0, 2_0, 3_0, 4_0)
       }

       for percentage, img in images.items():
              make_sepia(img, percentage)

       for percentage, img in images.items():
              imshow(F"Original image with sepia (factor: {percentage})", img)

       waitKey(0)
       destroyAllWindows()







'''simple docstring'''





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






class     lowercase  ( UpperCAmelCase_):
      __lowercase					=	['''image_processor''', '''tokenizer''']
      __lowercase					=	'''EfficientNetImageProcessor'''
      __lowercase					=	('''BertTokenizer''', '''BertTokenizerFast''')






      def __init__(self			,	a__			,	a__       )							-> Tuple:
         super().__init__(a__			,	a__       )






      def __call__(self			,	a__=None			,	a__=None			,	a__="max_length"			,	a__=6_4			,	a__=None			,	**a__       )							-> 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__      :					List[Any]							    =			self.tokenizer(
                a__			,	padding=a__			,	max_length=a__			,	return_tensors=a__			,	**a__       )

         if images is not None:
            SCREAMING_SNAKE_CASE__      :					Any							    =			self.image_processor(a__			,	return_tensors=a__			,	**a__       )

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






      def  A__(self			,	*a__			,	**a__       )							-> str:
         return self.tokenizer.batch_decode(*a__			,	**a__       )






      def  A__(self			,	*a__			,	**a__       )							-> str:
         return self.tokenizer.decode(*a__			,	**a__       )






      @property
      def  A__(self       )							-> Optional[int]:
         SCREAMING_SNAKE_CASE__      :					Optional[Any]							    =			self.tokenizer.model_input_names
         SCREAMING_SNAKE_CASE__      :					Tuple							    =			self.image_processor.model_input_names
         return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names       )       )

