processing_vilt.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright 2022 The HuggingFace Inc. team.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """
  15. Processor class for ViLT.
  16. """
  17. from ...processing_utils import ProcessingKwargs, ProcessorMixin
  18. from ...utils import auto_docstring
  19. class ViltProcessorKwargs(ProcessingKwargs, total=False):
  20. _defaults = {
  21. "text_kwargs": {
  22. "add_special_tokens": True,
  23. "padding": False,
  24. "stride": 0,
  25. "return_overflowing_tokens": False,
  26. "return_special_tokens_mask": False,
  27. "return_offsets_mapping": False,
  28. "return_length": False,
  29. "verbose": True,
  30. },
  31. }
  32. @auto_docstring
  33. class ViltProcessor(ProcessorMixin):
  34. valid_processor_kwargs = ViltProcessorKwargs
  35. def __init__(self, image_processor=None, tokenizer=None, **kwargs):
  36. super().__init__(image_processor, tokenizer)
  37. __all__ = ["ViltProcessor"]