processing_altclip.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # coding=utf-8
  2. # Copyright 2022 WenXiang ZhongzhiCheng LedellWu LiuGuang BoWenZhang The HuggingFace Inc. team. All rights reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """
  16. Image/Text processor class for AltCLIP
  17. """
  18. from ...processing_utils import ProcessorMixin
  19. from ...utils.deprecation import deprecate_kwarg
  20. class AltCLIPProcessor(ProcessorMixin):
  21. r"""
  22. Constructs a AltCLIP processor which wraps a CLIP image processor and a XLM-Roberta tokenizer into a single
  23. processor.
  24. [`AltCLIPProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`XLMRobertaTokenizerFast`]. See
  25. the [`~AltCLIPProcessor.__call__`] and [`~AltCLIPProcessor.decode`] for more information.
  26. Args:
  27. image_processor ([`CLIPImageProcessor`], *optional*):
  28. The image processor is a required input.
  29. tokenizer ([`XLMRobertaTokenizerFast`], *optional*):
  30. The tokenizer is a required input.
  31. """
  32. attributes = ["image_processor", "tokenizer"]
  33. image_processor_class = ("CLIPImageProcessor", "CLIPImageProcessorFast")
  34. tokenizer_class = ("XLMRobertaTokenizer", "XLMRobertaTokenizerFast")
  35. @deprecate_kwarg(old_name="feature_extractor", version="5.0.0", new_name="image_processor")
  36. def __init__(self, image_processor=None, tokenizer=None):
  37. super().__init__(image_processor, tokenizer)
  38. __all__ = ["AltCLIPProcessor"]