






'''simple docstring'''







import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin






class 					a__    (			lowerCamelCase						):
     '''simple docstring'''







     _snake_case             =  ['image_processor', 'tokenizer']
     _snake_case             =  'AutoImageProcessor'
     _snake_case             =  'AutoTokenizer'






     def __init__(self    :	Tuple				,				lowercase__    :	Union[str, Any]=None				,				lowercase__    :	Optional[Any]=None				,				**lowercase__    :	str					)  ->       Tuple:
           __A		   =      None
           if "feature_extractor" in kwargs:
                 warnings.warn(
                     "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
                     " instead."				,				lowercase__				,				)
                 __A		   =      kwargs.pop("feature_extractor"					)

           __A		   =      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__(lowercase__				,				lowercase__					)
           __A		   =      self.image_processor
           __A		   =      False






     def __call__(self    :	List[str]				,				*lowercase__    :	List[Any]				,				**lowercase__    :	List[str]					)  ->       str:
           # For backward compatibility
           if self._in_target_context_manager:
                 return self.current_processor(*lowercase__				,				**lowercase__					)

           __A		   =      kwargs.pop("images"				,				lowercase__					)
           __A		   =      kwargs.pop("text"				,				lowercase__					)
           if len(lowercase__					) > 0:
                 __A		   =      args[0]
                 __A		   =      args[1:]

           if images is None and text is None:
                 raise ValueError("You need to specify either an `images` or `text` input to process."					)

           if images is not None:
                 __A		   =      self.image_processor(lowercase__				,				*lowercase__				,				**lowercase__					)
           if text is not None:
                 __A		   =      self.tokenizer(lowercase__				,				**lowercase__					)

           if text is None:
                 return inputs
           elif images is None:
                 return encodings
           else:
                 __A		   =      encodings["input_ids"]
                 return inputs






     def     _UpperCamelCase   (self    :	Tuple				,				*lowercase__    :	List[Any]				,				**lowercase__    :	List[Any]					)  ->       Union[str, Any]:
           return self.tokenizer.batch_decode(*lowercase__				,				**lowercase__					)






     def     _UpperCamelCase   (self    :	List[str]				,				*lowercase__    :	Optional[Any]				,				**lowercase__    :	Any					)  ->       List[Any]:
           return self.tokenizer.decode(*lowercase__				,				**lowercase__					)






     @contextmanager
     def     _UpperCamelCase   (self    :	Dict					)  ->       Dict:
           warnings.warn(
               "`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your "
               "labels by using the argument `text` of the regular `__call__` method (either in the same call as "
               "your images inputs, or in a separate call."					)
           __A		   =      True
           __A		   =      self.tokenizer
           yield
           __A		   =      self.image_processor
           __A		   =      False






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






     @property
     def     _UpperCamelCase   (self    :	int					)  ->       Any:
           warnings.warn(
               "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."				,				lowercase__				,				)
           return self.image_processor










'''simple docstring'''







from typing import List

import datasets
from datasets.tasks import ImageClassification

from ..folder_based_builder import folder_based_builder


__A      :       Tuple      =	datasets.utils.logging.get_logger(__name__)






class 					a__    (			folder_based_builder.FolderBasedBuilderConfig						):
     '''simple docstring'''







     _snake_case             =  None
     _snake_case             =  None







class 					a__    (			folder_based_builder.FolderBasedBuilder						):
     '''simple docstring'''







     _snake_case             =  datasets.Image()
     _snake_case             =  'image'
     _snake_case             =  ImageFolderConfig
     _snake_case             =  42  # definition at the bottom of the script
     _snake_case             =  ImageClassification(image_column='image' ,						label_column='label'						)







__A      :       Any      =	[
    '.blp',
    '.bmp',
    '.dib',
    '.bufr',
    '.cur',
    '.pcx',
    '.dcx',
    '.dds',
    '.ps',
    '.eps',
    '.fit',
    '.fits',
    '.fli',
    '.flc',
    '.ftc',
    '.ftu',
    '.gbr',
    '.gif',
    '.grib',
    '.h5',
    '.hdf',
    '.png',
    '.apng',
    '.jp2',
    '.j2k',
    '.jpc',
    '.jpf',
    '.jpx',
    '.j2c',
    '.icns',
    '.ico',
    '.im',
    '.iim',
    '.tif',
    '.tiff',
    '.jfif',
    '.jpe',
    '.jpg',
    '.jpeg',
    '.mpg',
    '.mpeg',
    '.msp',
    '.pcd',
    '.pxr',
    '.pbm',
    '.pgm',
    '.ppm',
    '.pnm',
    '.psd',
    '.bw',
    '.rgb',
    '.rgba',
    '.sgi',
    '.ras',
    '.tga',
    '.icb',
    '.vda',
    '.vst',
    '.webp',
    '.wmf',
    '.emf',
    '.xbm',
    '.xpm',
]
__A      :       List[Any]      =	IMAGE_EXTENSIONS


