processing_git.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # coding=utf-8
  2. # Copyright 2022 The HuggingFace Inc. team.
  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 GIT
  17. """
  18. from ...processing_utils import ProcessorMixin
  19. class GitProcessor(ProcessorMixin):
  20. r"""
  21. Constructs a GIT processor which wraps a CLIP image processor and a BERT tokenizer into a single processor.
  22. [`GitProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`BertTokenizerFast`]. See the
  23. [`~GitProcessor.__call__`] and [`~GitProcessor.decode`] for more information.
  24. Args:
  25. image_processor ([`AutoImageProcessor`]):
  26. The image processor is a required input.
  27. tokenizer ([`AutoTokenizer`]):
  28. The tokenizer is a required input.
  29. """
  30. attributes = ["image_processor", "tokenizer"]
  31. image_processor_class = "AutoImageProcessor"
  32. tokenizer_class = "AutoTokenizer"
  33. def __init__(self, image_processor, tokenizer):
  34. super().__init__(image_processor, tokenizer)
  35. self.current_processor = self.image_processor
  36. __all__ = ["GitProcessor"]