processing_siglip.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # coding=utf-8
  2. # Copyright 2024 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 SigLIP.
  17. """
  18. from ...processing_utils import ProcessorMixin
  19. class SiglipProcessor(ProcessorMixin):
  20. r"""
  21. Constructs a Siglip processor which wraps a Siglip image processor and a Siglip tokenizer into a single processor.
  22. [`SiglipProcessor`] offers all the functionalities of [`SiglipImageProcessor`] and [`SiglipTokenizer`]. See the
  23. [`~SiglipProcessor.__call__`] and [`~SiglipProcessor.decode`] for more information.
  24. Args:
  25. image_processor ([`SiglipImageProcessor`]):
  26. The image processor is a required input.
  27. tokenizer ([`SiglipTokenizer`]):
  28. The tokenizer is a required input.
  29. """
  30. attributes = ["image_processor", "tokenizer"]
  31. image_processor_class = ("SiglipImageProcessor", "SiglipImageProcessorFast")
  32. tokenizer_class = "AutoTokenizer"
  33. def __init__(self, image_processor, tokenizer):
  34. super().__init__(image_processor, tokenizer)
  35. __all__ = ["SiglipProcessor"]