diff --git a/docs/source/en/model_doc/align.md b/docs/source/en/model_doc/align.md
index dbb11ae0ab36..3a4358525acc 100644
--- a/docs/source/en/model_doc/align.md
+++ b/docs/source/en/model_doc/align.md
@@ -166,6 +166,7 @@ for label, score in zip(candidate_labels, probs):
## AlignProcessor
[[autodoc]] AlignProcessor
+ - __call__
## AlignModel
diff --git a/docs/source/en/model_doc/altclip.md b/docs/source/en/model_doc/altclip.md
index f9d684e86289..3c52b8dc2d7f 100644
--- a/docs/source/en/model_doc/altclip.md
+++ b/docs/source/en/model_doc/altclip.md
@@ -126,3 +126,4 @@ for label, prob in zip(labels, probs[0]):
## AltCLIPProcessor
[[autodoc]] AltCLIPProcessor
+ - __call__
\ No newline at end of file
diff --git a/docs/source/en/model_doc/aria.md b/docs/source/en/model_doc/aria.md
index ddd0815aaa57..1d33981b334d 100644
--- a/docs/source/en/model_doc/aria.md
+++ b/docs/source/en/model_doc/aria.md
@@ -149,6 +149,7 @@ print(response)
## AriaProcessor
[[autodoc]] AriaProcessor
+ - __call__
## AriaTextConfig
diff --git a/docs/source/en/model_doc/audioflamingo3.md b/docs/source/en/model_doc/audioflamingo3.md
index 0031c9b0b3b8..a57897d691e4 100644
--- a/docs/source/en/model_doc/audioflamingo3.md
+++ b/docs/source/en/model_doc/audioflamingo3.md
@@ -390,6 +390,7 @@ are forwarded, so you can tweak padding or tensor formats just like when calling
## AudioFlamingo3Processor
[[autodoc]] AudioFlamingo3Processor
+ - __call__
## AudioFlamingo3Encoder
diff --git a/docs/source/en/model_doc/aya_vision.md b/docs/source/en/model_doc/aya_vision.md
index d0822173e898..4f3a77007d6a 100644
--- a/docs/source/en/model_doc/aya_vision.md
+++ b/docs/source/en/model_doc/aya_vision.md
@@ -260,6 +260,7 @@ print(processor.tokenizer.decode(generated[0], skip_special_tokens=True))
## AyaVisionProcessor
[[autodoc]] AyaVisionProcessor
+ - __call__
## AyaVisionConfig
diff --git a/docs/source/en/model_doc/blip-2.md b/docs/source/en/model_doc/blip-2.md
index 5f5d5efd7a15..e2a260f8def7 100644
--- a/docs/source/en/model_doc/blip-2.md
+++ b/docs/source/en/model_doc/blip-2.md
@@ -72,6 +72,7 @@ If you're interested in submitting a resource to be included here, please feel f
## Blip2Processor
[[autodoc]] Blip2Processor
+ - __call__
## Blip2VisionModel
diff --git a/docs/source/en/model_doc/blip.md b/docs/source/en/model_doc/blip.md
index 9c30c29ee5a1..15e6474da44d 100644
--- a/docs/source/en/model_doc/blip.md
+++ b/docs/source/en/model_doc/blip.md
@@ -99,6 +99,7 @@ Refer to this [notebook](https://github.com/huggingface/notebooks/blob/main/exam
## BlipProcessor
[[autodoc]] BlipProcessor
+ - __call__
## BlipImageProcessor
diff --git a/docs/source/en/model_doc/chameleon.md b/docs/source/en/model_doc/chameleon.md
index 65c0114fc7fb..3a9f1a707a46 100644
--- a/docs/source/en/model_doc/chameleon.md
+++ b/docs/source/en/model_doc/chameleon.md
@@ -182,6 +182,7 @@ model = ChameleonForConditionalGeneration.from_pretrained(
## ChameleonProcessor
[[autodoc]] ChameleonProcessor
+ - __call__
## ChameleonImageProcessor
diff --git a/docs/source/en/model_doc/chinese_clip.md b/docs/source/en/model_doc/chinese_clip.md
index c804ce3f04d7..5d1b71591d54 100644
--- a/docs/source/en/model_doc/chinese_clip.md
+++ b/docs/source/en/model_doc/chinese_clip.md
@@ -98,6 +98,7 @@ Currently, following scales of pretrained Chinese-CLIP models are available on
## ChineseCLIPProcessor
[[autodoc]] ChineseCLIPProcessor
+ - __call__
## ChineseCLIPModel
diff --git a/docs/source/en/model_doc/clap.md b/docs/source/en/model_doc/clap.md
index a1fe7753feb2..4c2db140bd18 100644
--- a/docs/source/en/model_doc/clap.md
+++ b/docs/source/en/model_doc/clap.md
@@ -79,6 +79,7 @@ print(f"Text embeddings: {text_features}")
## ClapProcessor
[[autodoc]] ClapProcessor
+ - __call__
## ClapModel
diff --git a/docs/source/en/model_doc/clip.md b/docs/source/en/model_doc/clip.md
index b58502a2b453..c341a6368bf2 100644
--- a/docs/source/en/model_doc/clip.md
+++ b/docs/source/en/model_doc/clip.md
@@ -119,6 +119,7 @@ print(f"Most likely label: {most_likely_label} with probability: {probs[0][most_
## CLIPProcessor
[[autodoc]] CLIPProcessor
+ - __call__
## CLIPModel
diff --git a/docs/source/en/model_doc/clipseg.md b/docs/source/en/model_doc/clipseg.md
index 6af0bb754de4..d305bf690a63 100644
--- a/docs/source/en/model_doc/clipseg.md
+++ b/docs/source/en/model_doc/clipseg.md
@@ -84,6 +84,7 @@ A list of official Hugging Face and community (indicated by 🌎) resources to h
## CLIPSegProcessor
[[autodoc]] CLIPSegProcessor
+ - __call__
## CLIPSegModel
diff --git a/docs/source/en/model_doc/cohere2_vision.md b/docs/source/en/model_doc/cohere2_vision.md
index e466ce6a5f09..49771d1feca4 100644
--- a/docs/source/en/model_doc/cohere2_vision.md
+++ b/docs/source/en/model_doc/cohere2_vision.md
@@ -139,3 +139,4 @@ print(outputs)
## Cohere2VisionProcessor
[[autodoc]] Cohere2VisionProcessor
+ - __call__
\ No newline at end of file
diff --git a/docs/source/en/model_doc/colpali.md b/docs/source/en/model_doc/colpali.md
index b6cc3d5c3e6a..42c880ea0926 100644
--- a/docs/source/en/model_doc/colpali.md
+++ b/docs/source/en/model_doc/colpali.md
@@ -164,6 +164,7 @@ print(scores)
## ColPaliProcessor
[[autodoc]] ColPaliProcessor
+ - __call__
## ColPaliForRetrieval
diff --git a/docs/source/en/model_doc/colqwen2.md b/docs/source/en/model_doc/colqwen2.md
index 7c9a9627e2c7..51393122c1da 100644
--- a/docs/source/en/model_doc/colqwen2.md
+++ b/docs/source/en/model_doc/colqwen2.md
@@ -189,6 +189,7 @@ processor = ColQwen2Processor.from_pretrained(model_name)
## ColQwen2Processor
[[autodoc]] ColQwen2Processor
+ - __call__
## ColQwen2ForRetrieval
diff --git a/docs/source/en/model_doc/deepseek_vl.md b/docs/source/en/model_doc/deepseek_vl.md
index 710e6144bb0e..7c5502849b7e 100644
--- a/docs/source/en/model_doc/deepseek_vl.md
+++ b/docs/source/en/model_doc/deepseek_vl.md
@@ -209,6 +209,7 @@ model = DeepseekVLForConditionalGeneration.from_pretrained(
## DeepseekVLProcessor
[[autodoc]] DeepseekVLProcessor
+ - __call__
## DeepseekVLImageProcessor
diff --git a/docs/source/en/model_doc/deepseek_vl_hybrid.md b/docs/source/en/model_doc/deepseek_vl_hybrid.md
index e779d0ac55f1..35cf380f95ba 100644
--- a/docs/source/en/model_doc/deepseek_vl_hybrid.md
+++ b/docs/source/en/model_doc/deepseek_vl_hybrid.md
@@ -208,6 +208,7 @@ model = DeepseekVLHybridForConditionalGeneration.from_pretrained(
## DeepseekVLHybridProcessor
[[autodoc]] DeepseekVLHybridProcessor
+ - __call__
## DeepseekVLHybridImageProcessor
diff --git a/docs/source/en/model_doc/emu3.md b/docs/source/en/model_doc/emu3.md
index 0c95bc6d9877..2da028e4665b 100644
--- a/docs/source/en/model_doc/emu3.md
+++ b/docs/source/en/model_doc/emu3.md
@@ -155,6 +155,7 @@ for i, image in enumerate(images['pixel_values']):
## Emu3Processor
[[autodoc]] Emu3Processor
+ - __call__
## Emu3ImageProcessor
diff --git a/docs/source/en/model_doc/ernie4_5_vl_moe.md b/docs/source/en/model_doc/ernie4_5_vl_moe.md
index 118ae3b5c0b9..71ffc1ba0a97 100644
--- a/docs/source/en/model_doc/ernie4_5_vl_moe.md
+++ b/docs/source/en/model_doc/ernie4_5_vl_moe.md
@@ -201,6 +201,7 @@ print(output_text)
## Ernie4_5_VL_MoeProcessor
[[autodoc]] Ernie4_5_VL_MoeProcessor
+ - __call__
## Ernie4_5_VL_MoeTextModel
diff --git a/docs/source/en/model_doc/flava.md b/docs/source/en/model_doc/flava.md
index 0449b99ace5c..0fb792e0106c 100644
--- a/docs/source/en/model_doc/flava.md
+++ b/docs/source/en/model_doc/flava.md
@@ -63,6 +63,7 @@ This model was contributed by [aps](https://huggingface.co/aps). The original co
## FlavaProcessor
[[autodoc]] FlavaProcessor
+ - __call__
## FlavaImageProcessor
diff --git a/docs/source/en/model_doc/florence2.md b/docs/source/en/model_doc/florence2.md
index 5d66e4e7a842..bc7dd1368e3d 100644
--- a/docs/source/en/model_doc/florence2.md
+++ b/docs/source/en/model_doc/florence2.md
@@ -171,6 +171,7 @@ print(parsed_answer)
## Florence2Processor
[[autodoc]] Florence2Processor
+ - __call__
## Florence2Model
diff --git a/docs/source/en/model_doc/gemma3.md b/docs/source/en/model_doc/gemma3.md
index 3c69cc1604ff..381a6a4ff0f6 100644
--- a/docs/source/en/model_doc/gemma3.md
+++ b/docs/source/en/model_doc/gemma3.md
@@ -243,6 +243,7 @@ visualizer("
What is shown in this image?")
## Gemma3Processor
[[autodoc]] Gemma3Processor
+ - __call__
## Gemma3TextConfig
diff --git a/docs/source/en/model_doc/gemma3n.md b/docs/source/en/model_doc/gemma3n.md
index 2d329bda6146..edfde4041395 100644
--- a/docs/source/en/model_doc/gemma3n.md
+++ b/docs/source/en/model_doc/gemma3n.md
@@ -161,6 +161,7 @@ echo -e "Plants create energy through a process known as" | transformers run --t
## Gemma3nProcessor
[[autodoc]] Gemma3nProcessor
+ - __call__
## Gemma3nTextConfig
diff --git a/docs/source/en/model_doc/glm46v.md b/docs/source/en/model_doc/glm46v.md
index 64666cea7588..ab62530a438a 100644
--- a/docs/source/en/model_doc/glm46v.md
+++ b/docs/source/en/model_doc/glm46v.md
@@ -39,6 +39,7 @@ rendered properly in your Markdown viewer.
## Glm46VProcessor
[[autodoc]] Glm46VProcessor
+ - __call__
## Glm46VModel
diff --git a/docs/source/en/model_doc/glm4v.md b/docs/source/en/model_doc/glm4v.md
index f6dea062afda..38e43ab5c5c8 100644
--- a/docs/source/en/model_doc/glm4v.md
+++ b/docs/source/en/model_doc/glm4v.md
@@ -196,6 +196,7 @@ print(output_text)
## Glm4vProcessor
[[autodoc]] Glm4vProcessor
+ - __call__
## Glm4vVisionModel
diff --git a/docs/source/en/model_doc/glmasr.md b/docs/source/en/model_doc/glmasr.md
index 7e7c8adc1d12..a895b778bedb 100644
--- a/docs/source/en/model_doc/glmasr.md
+++ b/docs/source/en/model_doc/glmasr.md
@@ -16,7 +16,7 @@ limitations under the License.
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer.
-->
-*This model was released on {release_date} and added to Hugging Face Transformers on 2025-12-15.*
+*This model was released on {release_date} and added to Hugging Face Transformers on 2025-12-24.*
# GlmAsr
@@ -162,6 +162,7 @@ print(decoded_outputs)
## GlmAsrProcessor
[[autodoc]] GlmAsrProcessor
+ - __call__
## GlmAsrEncoder
diff --git a/docs/source/en/model_doc/got_ocr2.md b/docs/source/en/model_doc/got_ocr2.md
index 3c4225ccaef7..8deb85fb144c 100644
--- a/docs/source/en/model_doc/got_ocr2.md
+++ b/docs/source/en/model_doc/got_ocr2.md
@@ -281,6 +281,7 @@ alt="drawing" width="600"/>
## GotOcr2Processor
[[autodoc]] GotOcr2Processor
+ - __call__
## GotOcr2Model
diff --git a/docs/source/en/model_doc/granite_speech.md b/docs/source/en/model_doc/granite_speech.md
index 62cb2994467f..286d62bd9341 100644
--- a/docs/source/en/model_doc/granite_speech.md
+++ b/docs/source/en/model_doc/granite_speech.md
@@ -160,6 +160,7 @@ for i, transcription in enumerate(transcriptions):
## GraniteSpeechProcessor
[[autodoc]] GraniteSpeechProcessor
+ - __call__
## GraniteSpeechFeatureExtractor
diff --git a/docs/source/en/model_doc/granitevision.md b/docs/source/en/model_doc/granitevision.md
index 17b499215def..3c3181752030 100644
--- a/docs/source/en/model_doc/granitevision.md
+++ b/docs/source/en/model_doc/granitevision.md
@@ -85,6 +85,7 @@ This model was contributed by [Alexander Brooks](https://huggingface.co/abrooks9
## LlavaNextProcessor
[[autodoc]] LlavaNextProcessor
+ - __call__
## LlavaNextForConditionalGeneration
diff --git a/docs/source/en/model_doc/grounding-dino.md b/docs/source/en/model_doc/grounding-dino.md
index fd2c1d5092f1..bdae28b076c3 100644
--- a/docs/source/en/model_doc/grounding-dino.md
+++ b/docs/source/en/model_doc/grounding-dino.md
@@ -114,6 +114,7 @@ A list of official Hugging Face and community (indicated by 🌎) resources to h
## GroundingDinoProcessor
[[autodoc]] GroundingDinoProcessor
+ - __call__
- post_process_grounded_object_detection
## GroundingDinoConfig
diff --git a/docs/source/en/model_doc/instructblip.md b/docs/source/en/model_doc/instructblip.md
index 7cbab82b287e..e2fef6c1e35c 100644
--- a/docs/source/en/model_doc/instructblip.md
+++ b/docs/source/en/model_doc/instructblip.md
@@ -57,6 +57,7 @@ The attributes can be obtained from model config, as `model.config.num_query_tok
## InstructBlipProcessor
[[autodoc]] InstructBlipProcessor
+ - __call__
## InstructBlipVisionModel
diff --git a/docs/source/en/model_doc/internvl.md b/docs/source/en/model_doc/internvl.md
index 96809b45ce56..e2a712697d1d 100644
--- a/docs/source/en/model_doc/internvl.md
+++ b/docs/source/en/model_doc/internvl.md
@@ -348,6 +348,7 @@ This example showcases how to handle a batch of chat conversations with interlea
## InternVLProcessor
[[autodoc]] InternVLProcessor
+ - __call__
## InternVLVideoProcessor
diff --git a/docs/source/en/model_doc/janus.md b/docs/source/en/model_doc/janus.md
index c815b29cdbc0..916592489b5f 100644
--- a/docs/source/en/model_doc/janus.md
+++ b/docs/source/en/model_doc/janus.md
@@ -205,6 +205,7 @@ for i, image in enumerate(images['pixel_values']):
## JanusProcessor
[[autodoc]] JanusProcessor
+ - __call__
## JanusImageProcessor
diff --git a/docs/source/en/model_doc/kosmos2_5.md b/docs/source/en/model_doc/kosmos2_5.md
index 7fce9eaf8b15..8fa5fd30c5eb 100644
--- a/docs/source/en/model_doc/kosmos2_5.md
+++ b/docs/source/en/model_doc/kosmos2_5.md
@@ -224,6 +224,7 @@ print(generated_text[0])
## Kosmos2_5Processor
[[autodoc]] Kosmos2_5Processor
+ - __call__
## Kosmos2_5Model
diff --git a/docs/source/en/model_doc/lfm2_vl.md b/docs/source/en/model_doc/lfm2_vl.md
index fb6b2ad8a4e2..de77b984369d 100644
--- a/docs/source/en/model_doc/lfm2_vl.md
+++ b/docs/source/en/model_doc/lfm2_vl.md
@@ -82,6 +82,7 @@ processor.batch_decode(outputs, skip_special_tokens=True)[0]
## Lfm2VlProcessor
[[autodoc]] Lfm2VlProcessor
+ - __call__
## Lfm2VlConfig
diff --git a/docs/source/en/model_doc/llama4.md b/docs/source/en/model_doc/llama4.md
index 09e2af47b965..6ccb3190e485 100644
--- a/docs/source/en/model_doc/llama4.md
+++ b/docs/source/en/model_doc/llama4.md
@@ -416,6 +416,7 @@ model = Llama4ForConditionalGeneration.from_pretrained(
## Llama4Processor
[[autodoc]] Llama4Processor
+ - __call__
## Llama4ImageProcessorFast
diff --git a/docs/source/en/model_doc/llava.md b/docs/source/en/model_doc/llava.md
index e387fb4b54c7..2adaa15db8f3 100644
--- a/docs/source/en/model_doc/llava.md
+++ b/docs/source/en/model_doc/llava.md
@@ -250,6 +250,7 @@ A list of official Hugging Face and community (indicated by 🌎) resources to h
## LlavaProcessor
[[autodoc]] LlavaProcessor
+ - __call__
## LlavaModel
diff --git a/docs/source/en/model_doc/llava_next.md b/docs/source/en/model_doc/llava_next.md
index e07f54727161..11a7a8dfe76c 100644
--- a/docs/source/en/model_doc/llava_next.md
+++ b/docs/source/en/model_doc/llava_next.md
@@ -206,6 +206,7 @@ print(processor.decode(output[0], skip_special_tokens=True))
## LlavaNextProcessor
[[autodoc]] LlavaNextProcessor
+ - __call__
## LlavaNextModel
diff --git a/docs/source/en/model_doc/llava_onevision.md b/docs/source/en/model_doc/llava_onevision.md
index fe883f8dd694..c271421862fe 100644
--- a/docs/source/en/model_doc/llava_onevision.md
+++ b/docs/source/en/model_doc/llava_onevision.md
@@ -298,6 +298,7 @@ model = LlavaOnevisionForConditionalGeneration.from_pretrained(
## LlavaOnevisionProcessor
[[autodoc]] LlavaOnevisionProcessor
+ - __call__
## LlavaOnevisionImageProcessor
diff --git a/docs/source/en/model_doc/mllama.md b/docs/source/en/model_doc/mllama.md
index afb1f5d14b2d..e39eaace30e5 100644
--- a/docs/source/en/model_doc/mllama.md
+++ b/docs/source/en/model_doc/mllama.md
@@ -108,6 +108,7 @@ print(processor.decode(output[0], skip_special_tokens=True))
## MllamaProcessor
[[autodoc]] MllamaProcessor
+ - __call__
## MllamaImageProcessor
diff --git a/docs/source/en/model_doc/musicgen.md b/docs/source/en/model_doc/musicgen.md
index 5076e60b6e97..8c4319710b9c 100644
--- a/docs/source/en/model_doc/musicgen.md
+++ b/docs/source/en/model_doc/musicgen.md
@@ -272,6 +272,7 @@ Tips:
## MusicgenProcessor
[[autodoc]] MusicgenProcessor
+ - __call__
## MusicgenModel
diff --git a/docs/source/en/model_doc/musicgen_melody.md b/docs/source/en/model_doc/musicgen_melody.md
index cd0c669cf577..5b3b8e3a777e 100644
--- a/docs/source/en/model_doc/musicgen_melody.md
+++ b/docs/source/en/model_doc/musicgen_melody.md
@@ -266,6 +266,7 @@ Tips:
## MusicgenMelodyProcessor
[[autodoc]] MusicgenMelodyProcessor
+ - __call__
- get_unconditional_inputs
## MusicgenMelodyFeatureExtractor
diff --git a/docs/source/en/model_doc/omdet-turbo.md b/docs/source/en/model_doc/omdet-turbo.md
index 408e1b02f645..5aa94ad350c0 100644
--- a/docs/source/en/model_doc/omdet-turbo.md
+++ b/docs/source/en/model_doc/omdet-turbo.md
@@ -164,6 +164,7 @@ Detected statue with confidence 0.2 at location [428.1, 205.5, 767.3, 759.5] in
## OmDetTurboProcessor
[[autodoc]] OmDetTurboProcessor
+ - __call__
- post_process_grounded_object_detection
## OmDetTurboForObjectDetection
diff --git a/docs/source/en/model_doc/oneformer.md b/docs/source/en/model_doc/oneformer.md
index 7f5d32bc55a8..87a926e18906 100644
--- a/docs/source/en/model_doc/oneformer.md
+++ b/docs/source/en/model_doc/oneformer.md
@@ -85,6 +85,7 @@ The resource should ideally demonstrate something new instead of duplicating an
## OneFormerProcessor
[[autodoc]] OneFormerProcessor
+ - __call__
## OneFormerModel
diff --git a/docs/source/en/model_doc/ovis2.md b/docs/source/en/model_doc/ovis2.md
index 1671f2d42e2f..eacce1b30b38 100644
--- a/docs/source/en/model_doc/ovis2.md
+++ b/docs/source/en/model_doc/ovis2.md
@@ -107,3 +107,4 @@ with torch.inference_mode():
## Ovis2Processor
[[autodoc]] Ovis2Processor
+ - __call__
\ No newline at end of file
diff --git a/docs/source/en/model_doc/paddleocr_vl.md b/docs/source/en/model_doc/paddleocr_vl.md
index 79c3dea96eb0..cc4df0774316 100644
--- a/docs/source/en/model_doc/paddleocr_vl.md
+++ b/docs/source/en/model_doc/paddleocr_vl.md
@@ -242,6 +242,7 @@ model = AutoModelForImageTextToText.from_pretrained("PaddlePaddle/PaddleOCR-VL",
## PaddleOCRVLProcessor
[[autodoc]] PaddleOCRVLProcessor
+ - __call__
## PaddleOCRVisionTransformer
diff --git a/docs/source/en/model_doc/paligemma.md b/docs/source/en/model_doc/paligemma.md
index fa7c193da453..638d5f47ebc2 100644
--- a/docs/source/en/model_doc/paligemma.md
+++ b/docs/source/en/model_doc/paligemma.md
@@ -175,6 +175,7 @@ visualizer("
What is in this image?")
## PaliGemmaProcessor
[[autodoc]] PaliGemmaProcessor
+ - __call__
## PaliGemmaModel
diff --git a/docs/source/en/model_doc/perception_lm.md b/docs/source/en/model_doc/perception_lm.md
index 7d3d608253fc..ca99d1e4cd62 100644
--- a/docs/source/en/model_doc/perception_lm.md
+++ b/docs/source/en/model_doc/perception_lm.md
@@ -48,6 +48,7 @@ The original code can be found [here](https://github.com/facebookresearch/percep
## PerceptionLMProcessor
[[autodoc]] PerceptionLMProcessor
+ - __call__
## PerceptionLMImageProcessorFast
diff --git a/docs/source/en/model_doc/phi4_multimodal.md b/docs/source/en/model_doc/phi4_multimodal.md
index c7bc70086df6..a52249640726 100644
--- a/docs/source/en/model_doc/phi4_multimodal.md
+++ b/docs/source/en/model_doc/phi4_multimodal.md
@@ -152,6 +152,7 @@ print(f'>>> Response\n{response}')
## Phi4MultimodalProcessor
[[autodoc]] Phi4MultimodalProcessor
+ - __call__
## Phi4MultimodalAudioConfig
diff --git a/docs/source/en/model_doc/pix2struct.md b/docs/source/en/model_doc/pix2struct.md
index 6a68b6381a01..5bb276999cbd 100644
--- a/docs/source/en/model_doc/pix2struct.md
+++ b/docs/source/en/model_doc/pix2struct.md
@@ -59,6 +59,7 @@ The original code can be found [here](https://github.com/google-research/pix2str
## Pix2StructProcessor
[[autodoc]] Pix2StructProcessor
+ - __call__
## Pix2StructImageProcessor
diff --git a/docs/source/en/model_doc/pixtral.md b/docs/source/en/model_doc/pixtral.md
index 548058c3ec18..53bf01cc5b1e 100644
--- a/docs/source/en/model_doc/pixtral.md
+++ b/docs/source/en/model_doc/pixtral.md
@@ -160,3 +160,4 @@ print(output)
## PixtralProcessor
[[autodoc]] PixtralProcessor
+ - __call__
\ No newline at end of file
diff --git a/docs/source/en/model_doc/qwen2_5_omni.md b/docs/source/en/model_doc/qwen2_5_omni.md
index 8153589e5cca..7b68c6283059 100644
--- a/docs/source/en/model_doc/qwen2_5_omni.md
+++ b/docs/source/en/model_doc/qwen2_5_omni.md
@@ -349,6 +349,7 @@ model = Qwen2_5OmniForConditionalGeneration.from_pretrained(
## Qwen2_5OmniProcessor
[[autodoc]] Qwen2_5OmniProcessor
+ - __call__
## Qwen2_5OmniForConditionalGeneration
diff --git a/docs/source/en/model_doc/qwen2_5_vl.md b/docs/source/en/model_doc/qwen2_5_vl.md
index 7f682bf80201..693172157317 100644
--- a/docs/source/en/model_doc/qwen2_5_vl.md
+++ b/docs/source/en/model_doc/qwen2_5_vl.md
@@ -246,6 +246,7 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
## Qwen2_5_VLProcessor
[[autodoc]] Qwen2_5_VLProcessor
+ - __call__
## Qwen2_5_VLTextModel
diff --git a/docs/source/en/model_doc/qwen2_vl.md b/docs/source/en/model_doc/qwen2_vl.md
index 59dc25b5e085..6960f7f07b03 100644
--- a/docs/source/en/model_doc/qwen2_vl.md
+++ b/docs/source/en/model_doc/qwen2_vl.md
@@ -302,6 +302,7 @@ model = Qwen2VLForConditionalGeneration.from_pretrained(
## Qwen2VLProcessor
[[autodoc]] Qwen2VLProcessor
+ - __call__
## Qwen2VLTextModel
diff --git a/docs/source/en/model_doc/qwen3_omni_moe.md b/docs/source/en/model_doc/qwen3_omni_moe.md
index 75dea355e4bb..ee07ce138676 100644
--- a/docs/source/en/model_doc/qwen3_omni_moe.md
+++ b/docs/source/en/model_doc/qwen3_omni_moe.md
@@ -389,6 +389,7 @@ model = Qwen3OmniMoeForConditionalGeneration.from_pretrained(
## Qwen3OmniMoeProcessor
[[autodoc]] Qwen3OmniMoeProcessor
+ - __call__
## Qwen3OmniMoeCode2Wav
diff --git a/docs/source/en/model_doc/qwen3_vl.md b/docs/source/en/model_doc/qwen3_vl.md
index 33c8c7e96aee..856c92cf9897 100644
--- a/docs/source/en/model_doc/qwen3_vl.md
+++ b/docs/source/en/model_doc/qwen3_vl.md
@@ -92,6 +92,7 @@ print(output_text)
## Qwen3VLProcessor
[[autodoc]] Qwen3VLProcessor
+ - __call__
## Qwen3VLVideoProcessor
diff --git a/docs/source/en/model_doc/sam.md b/docs/source/en/model_doc/sam.md
index 8361144e262f..b770e41663e1 100644
--- a/docs/source/en/model_doc/sam.md
+++ b/docs/source/en/model_doc/sam.md
@@ -143,6 +143,7 @@ alt="drawing" width="900"/>
## SamProcessor
[[autodoc]] SamProcessor
+ - __call__
## SamImageProcessor
diff --git a/docs/source/en/model_doc/sam_hq.md b/docs/source/en/model_doc/sam_hq.md
index 394beb9b3e43..a73d791f63e6 100644
--- a/docs/source/en/model_doc/sam_hq.md
+++ b/docs/source/en/model_doc/sam_hq.md
@@ -132,6 +132,7 @@ A list of official Hugging Face and community (indicated by 🌎) resources to h
## SamHQProcessor
[[autodoc]] SamHQProcessor
+ - __call__
## SamHQVisionModel
diff --git a/docs/source/en/model_doc/shieldgemma2.md b/docs/source/en/model_doc/shieldgemma2.md
index 6a67c2d61b5a..55a5d8bf57c8 100644
--- a/docs/source/en/model_doc/shieldgemma2.md
+++ b/docs/source/en/model_doc/shieldgemma2.md
@@ -89,6 +89,7 @@ print(output.probabilities)
## ShieldGemma2Processor
[[autodoc]] ShieldGemma2Processor
+ - __call__
## ShieldGemma2Config
diff --git a/docs/source/en/model_doc/siglip.md b/docs/source/en/model_doc/siglip.md
index 28def85a8b03..ba31f837d6d4 100644
--- a/docs/source/en/model_doc/siglip.md
+++ b/docs/source/en/model_doc/siglip.md
@@ -160,6 +160,7 @@ print(f"{probs[0][0]:.1%} that image 0 is '{candidate_labels[0]}'")
## SiglipProcessor
[[autodoc]] SiglipProcessor
+ - __call__
## SiglipModel
diff --git a/docs/source/en/model_doc/siglip2.md b/docs/source/en/model_doc/siglip2.md
index 6a058f8907a4..b8fa5d1256b4 100644
--- a/docs/source/en/model_doc/siglip2.md
+++ b/docs/source/en/model_doc/siglip2.md
@@ -195,6 +195,7 @@ print(f"{probs[0][0]:.1%} that image 0 is '{candidate_labels[0]}'")
## Siglip2Processor
[[autodoc]] Siglip2Processor
+ - __call__
## Siglip2Model
diff --git a/docs/source/en/model_doc/video_llama_3.md b/docs/source/en/model_doc/video_llama_3.md
index f0f11c66d25b..dc5c8f1c2a22 100644
--- a/docs/source/en/model_doc/video_llama_3.md
+++ b/docs/source/en/model_doc/video_llama_3.md
@@ -212,6 +212,7 @@ model = VideoLlama3ForConditionalGeneration.from_pretrained(
## VideoLlama3Processor
[[autodoc]] VideoLlama3Processor
+ - __call__
## VideoLlama3Model
diff --git a/docs/source/en/model_doc/video_llava.md b/docs/source/en/model_doc/video_llava.md
index 5fb3cbbd25a4..24437684716f 100644
--- a/docs/source/en/model_doc/video_llava.md
+++ b/docs/source/en/model_doc/video_llava.md
@@ -213,6 +213,7 @@ model = VideoLlavaForConditionalGeneration.from_pretrained(
## VideoLlavaProcessor
[[autodoc]] VideoLlavaProcessor
+ - __call__
## VideoLlavaModel
diff --git a/docs/source/en/model_doc/vision-text-dual-encoder.md b/docs/source/en/model_doc/vision-text-dual-encoder.md
index 9243aa30d97f..d4ba9878bdbd 100644
--- a/docs/source/en/model_doc/vision-text-dual-encoder.md
+++ b/docs/source/en/model_doc/vision-text-dual-encoder.md
@@ -42,6 +42,7 @@ new zero-shot vision tasks such as image classification or retrieval.
## VisionTextDualEncoderProcessor
[[autodoc]] VisionTextDualEncoderProcessor
+ - __call__
## VisionTextDualEncoderModel
diff --git a/docs/source/en/model_doc/voxtral.md b/docs/source/en/model_doc/voxtral.md
index 5c2d2c4fa229..b22bb18efab1 100644
--- a/docs/source/en/model_doc/voxtral.md
+++ b/docs/source/en/model_doc/voxtral.md
@@ -359,6 +359,7 @@ This model was contributed by [Eustache Le Bihan](https://huggingface.co/eustlb)
## VoxtralProcessor
[[autodoc]] VoxtralProcessor
+ - __call__
## VoxtralEncoder
diff --git a/docs/source/en/model_doc/xclip.md b/docs/source/en/model_doc/xclip.md
index 529879c7bcb3..c0a9cdc0ab6f 100644
--- a/docs/source/en/model_doc/xclip.md
+++ b/docs/source/en/model_doc/xclip.md
@@ -53,6 +53,7 @@ If you're interested in submitting a resource to be included here, please feel f
## XCLIPProcessor
[[autodoc]] XCLIPProcessor
+ - __call__
## XCLIPConfig
diff --git a/src/transformers/models/align/processing_align.py b/src/transformers/models/align/processing_align.py
index addf0df79e37..fa15fcce3de6 100644
--- a/src/transformers/models/align/processing_align.py
+++ b/src/transformers/models/align/processing_align.py
@@ -16,6 +16,7 @@
"""
from ...processing_utils import ProcessingKwargs, ProcessorMixin
+from ...utils import auto_docstring
class AlignProcessorKwargs(ProcessingKwargs, total=False):
@@ -28,36 +29,8 @@ class AlignProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class AlignProcessor(ProcessorMixin):
- r"""
- Constructs an ALIGN processor which wraps [`EfficientNetImageProcessor`] and
- [`BertTokenizer`]/[`BertTokenizerFast`] into a single processor that inherits both the image processor and
- tokenizer functionalities. See the [`~AlignProcessor.__call__`] and [`~OwlViTProcessor.decode`] for more
- information.
- The preferred way of passing kwargs is as a dictionary per modality, see usage example below.
- ```python
- from transformers import AlignProcessor
- from PIL import Image
- model_id = "kakaobrain/align-base"
- processor = AlignProcessor.from_pretrained(model_id)
-
- processor(
- images=your_pil_image,
- text=["What is that?"],
- images_kwargs = {"crop_size": {"height": 224, "width": 224}},
- text_kwargs = {"padding": "do_not_pad"},
- common_kwargs = {"return_tensors": "pt"},
- )
- ```
-
- Args:
- image_processor ([`EfficientNetImageProcessor`]):
- The image processor is a required input.
- tokenizer ([`BertTokenizer`, `BertTokenizerFast`]):
- The tokenizer is a required input.
-
- """
-
valid_processor_kwargs = AlignProcessorKwargs
def __init__(self, image_processor, tokenizer):
diff --git a/src/transformers/models/altclip/processing_altclip.py b/src/transformers/models/altclip/processing_altclip.py
index 0891234659dc..78fd31be5f22 100644
--- a/src/transformers/models/altclip/processing_altclip.py
+++ b/src/transformers/models/altclip/processing_altclip.py
@@ -16,23 +16,11 @@
"""
from ...processing_utils import ProcessorMixin
+from ...utils import auto_docstring
+@auto_docstring
class AltCLIPProcessor(ProcessorMixin):
- r"""
- Constructs a AltCLIP processor which wraps a CLIP image processor and a XLM-Roberta tokenizer into a single
- processor.
-
- [`AltCLIPProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`XLMRobertaTokenizerFast`]. See
- the [`~AltCLIPProcessor.__call__`] and [`~AltCLIPProcessor.decode`] for more information.
-
- Args:
- image_processor ([`CLIPImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`XLMRobertaTokenizerFast`], *optional*):
- The tokenizer is a required input.
- """
-
def __init__(self, image_processor=None, tokenizer=None):
super().__init__(image_processor, tokenizer)
diff --git a/src/transformers/models/aria/modular_aria.py b/src/transformers/models/aria/modular_aria.py
index cba7c237cd4f..01ff43cef531 100644
--- a/src/transformers/models/aria/modular_aria.py
+++ b/src/transformers/models/aria/modular_aria.py
@@ -878,6 +878,21 @@ def get_number_of_image_patches(self, height: int, width: int, images_kwargs=Non
class AriaImagesKwargs(ImagesKwargs, total=False):
+ """
+ split_image (`bool`, *optional*, defaults to `False`):
+ Whether to split large images into multiple crops. When enabled, images exceeding the maximum size are
+ divided into overlapping crops that are processed separately and then combined. This allows processing
+ of very high-resolution images that exceed the model's input size limits.
+ max_image_size (`int`, *optional*, defaults to `980`):
+ Maximum image size (in pixels) for a single image crop. Images larger than this will be split into
+ multiple crops when `split_image=True`, or resized if splitting is disabled. This parameter controls
+ the maximum resolution of individual image patches processed by the model.
+ min_image_size (`int`, *optional*):
+ Minimum image size (in pixels) for a single image crop. Images smaller than this will be upscaled to
+ meet the minimum requirement. If not specified, images are processed at their original size (subject
+ to the maximum size constraint).
+ """
+
split_image: bool
max_image_size: int
min_image_size: int
@@ -899,21 +914,8 @@ class AriaProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class AriaProcessor(ProcessorMixin):
- """
- AriaProcessor is a processor for the Aria model which wraps the Aria image preprocessor and the LLama slow tokenizer.
-
- Args:
- image_processor (`AriaImageProcessor`, *optional*):
- The AriaImageProcessor to use for image preprocessing.
- tokenizer (`PreTrainedTokenizerBase`, *optional*):
- An instance of [`PreTrainedTokenizerBase`]. This should correspond with the model's text model. The tokenizer is a required input.
- chat_template (`str`, *optional*):
- A Jinja template which will be used to convert lists of messages in a chat into a tokenizable string.
- size_conversion (`Dict`, *optional*):
- A dictionary indicating size conversions for images.
- """
-
def __init__(
self,
image_processor=None,
@@ -921,6 +923,10 @@ def __init__(
chat_template: str | None = None,
size_conversion: dict[float | int, int] | None = None,
):
+ r"""
+ size_conversion (`Dict`, *optional*):
+ A dictionary indicating size conversions for images.
+ """
if size_conversion is None:
size_conversion = {490: 128, 980: 256}
self.size_conversion = {int(k): v for k, v in size_conversion.items()}
@@ -932,25 +938,14 @@ def __init__(
super().__init__(image_processor, tokenizer, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput],
images: ImageInput | None = None,
**kwargs: Unpack[AriaProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s).
-
- Args:
- text (`TextInput`, `PreTokenizedInput`, `list[TextInput]`, `list[PreTokenizedInput]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- images (`ImageInput`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
-
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
- **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`.
diff --git a/src/transformers/models/aria/processing_aria.py b/src/transformers/models/aria/processing_aria.py
index e36e7773b8b8..c712c6ef585f 100644
--- a/src/transformers/models/aria/processing_aria.py
+++ b/src/transformers/models/aria/processing_aria.py
@@ -24,11 +24,26 @@
from ...image_utils import ImageInput
from ...processing_utils import ImagesKwargs, MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_python import PreTokenizedInput, TextInput
-from ...utils import TensorType
+from ...utils import TensorType, auto_docstring
from ..auto import AutoTokenizer
class AriaImagesKwargs(ImagesKwargs, total=False):
+ """
+ split_image (`bool`, *optional*, defaults to `False`):
+ Whether to split large images into multiple crops. When enabled, images exceeding the maximum size are
+ divided into overlapping crops that are processed separately and then combined. This allows processing
+ of very high-resolution images that exceed the model's input size limits.
+ max_image_size (`int`, *optional*, defaults to `980`):
+ Maximum image size (in pixels) for a single image crop. Images larger than this will be split into
+ multiple crops when `split_image=True`, or resized if splitting is disabled. This parameter controls
+ the maximum resolution of individual image patches processed by the model.
+ min_image_size (`int`, *optional*):
+ Minimum image size (in pixels) for a single image crop. Images smaller than this will be upscaled to
+ meet the minimum requirement. If not specified, images are processed at their original size (subject
+ to the maximum size constraint).
+ """
+
split_image: bool
max_image_size: int
min_image_size: int
@@ -50,21 +65,8 @@ class AriaProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class AriaProcessor(ProcessorMixin):
- """
- AriaProcessor is a processor for the Aria model which wraps the Aria image preprocessor and the LLama slow tokenizer.
-
- Args:
- image_processor (`AriaImageProcessor`, *optional*):
- The AriaImageProcessor to use for image preprocessing.
- tokenizer (`PreTrainedTokenizerBase`, *optional*):
- An instance of [`PreTrainedTokenizerBase`]. This should correspond with the model's text model. The tokenizer is a required input.
- chat_template (`str`, *optional*):
- A Jinja template which will be used to convert lists of messages in a chat into a tokenizable string.
- size_conversion (`Dict`, *optional*):
- A dictionary indicating size conversions for images.
- """
-
def __init__(
self,
image_processor=None,
@@ -72,6 +74,10 @@ def __init__(
chat_template: str | None = None,
size_conversion: dict[float | int, int] | None = None,
):
+ r"""
+ size_conversion (`Dict`, *optional*):
+ A dictionary indicating size conversions for images.
+ """
if size_conversion is None:
size_conversion = {490: 128, 980: 256}
self.size_conversion = {int(k): v for k, v in size_conversion.items()}
@@ -83,25 +89,14 @@ def __init__(
super().__init__(image_processor, tokenizer, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput],
images: ImageInput | None = None,
**kwargs: Unpack[AriaProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s).
-
- Args:
- text (`TextInput`, `PreTokenizedInput`, `list[TextInput]`, `list[PreTokenizedInput]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- images (`ImageInput`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
-
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
- **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`.
diff --git a/src/transformers/models/auto/image_processing_auto.py b/src/transformers/models/auto/image_processing_auto.py
index f330c3c4bab6..054f79209daa 100644
--- a/src/transformers/models/auto/image_processing_auto.py
+++ b/src/transformers/models/auto/image_processing_auto.py
@@ -177,6 +177,8 @@
("sam2", (None, "Sam2ImageProcessorFast")),
("sam2_video", (None, "Sam2ImageProcessorFast")),
("sam3", (None, "Sam3ImageProcessorFast")),
+ ("sam3_tracker", (None, "Sam3ImageProcessorFast")),
+ ("sam3_tracker_video", (None, "Sam3ImageProcessorFast")),
("sam3_video", (None, "Sam3ImageProcessorFast")),
("sam_hq", ("SamImageProcessor", "SamImageProcessorFast")),
("segformer", ("SegformerImageProcessor", "SegformerImageProcessorFast")),
diff --git a/src/transformers/models/auto/tokenization_auto.py b/src/transformers/models/auto/tokenization_auto.py
index de522d4ef0ca..b5c3a379cfd7 100644
--- a/src/transformers/models/auto/tokenization_auto.py
+++ b/src/transformers/models/auto/tokenization_auto.py
@@ -265,6 +265,8 @@
("roc_bert", "RoCBertTokenizer"),
("roformer", "RoFormerTokenizer" if is_tokenizers_available() else None),
("rwkv", "GPTNeoXTokenizer" if is_tokenizers_available() else None),
+ ("sam3", "CLIPTokenizer" if is_tokenizers_available() else None),
+ ("sam3_video", "CLIPTokenizer" if is_tokenizers_available() else None),
("seamless_m4t", "SeamlessM4TTokenizer" if is_tokenizers_available() else None),
("seamless_m4t_v2", "SeamlessM4TTokenizer" if is_tokenizers_available() else None),
("shieldgemma2", "GemmaTokenizer" if is_tokenizers_available() else None),
diff --git a/src/transformers/models/aya_vision/processing_aya_vision.py b/src/transformers/models/aya_vision/processing_aya_vision.py
index 5dd80e4b0f46..4fdc5dca70a8 100644
--- a/src/transformers/models/aya_vision/processing_aya_vision.py
+++ b/src/transformers/models/aya_vision/processing_aya_vision.py
@@ -20,6 +20,7 @@
from ...image_utils import ImageInput, make_flat_list_of_images
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
+from ...utils import auto_docstring
class AyaVisionProcessorKwargs(ProcessingKwargs, total=False):
@@ -35,16 +36,26 @@ class AyaVisionProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class AyaVisionProcessor(ProcessorMixin):
- r"""
- Constructs a AyaVision processor which wraps a [`AutoImageProcessor`] and
- [`PretrainedTokenizerFast`] tokenizer into a single processor that inherits both the image processor and
- tokenizer functionalities. See the [`~AyaVisionProcessor.__call__`] and [`~AyaVisionProcessor.decode`] for more information.
- Args:
- image_processor ([`AutoImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`PreTrainedTokenizer`, `PreTrainedTokenizerFast`], *optional*):
- The tokenizer is a required input.
+ def __init__(
+ self,
+ image_processor=None,
+ tokenizer=None,
+ patch_size: int = 28,
+ img_size: int = 364,
+ image_token="", # set the default and let users change if they have peculiar special tokens in rare cases
+ downsample_factor: int = 1,
+ start_of_img_token="<|START_OF_IMG|>",
+ end_of_img_token="<|END_OF_IMG|>",
+ img_patch_token="<|IMG_PATCH|>",
+ img_line_break_token="<|IMG_LINE_BREAK|>",
+ tile_token="TILE",
+ tile_global_token="TILE_GLOBAL",
+ chat_template=None,
+ **kwargs,
+ ):
+ r"""
patch_size (`int`, *optional*, defaults to 28):
The size of image patches for tokenization.
img_size (`int`, *optional*, defaults to 364):
@@ -65,27 +76,7 @@ class AyaVisionProcessor(ProcessorMixin):
The token to be used to represent an image patch in the text.
tile_global_token (`str`, *optional*, defaults to `"TILE_GLOBAL"`):
The token to be used to represent the cover image in the text.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
- def __init__(
- self,
- image_processor=None,
- tokenizer=None,
- patch_size: int = 28,
- img_size: int = 364,
- image_token="", # set the default and let users change if they have peculiar special tokens in rare cases
- downsample_factor: int = 1,
- start_of_img_token="<|START_OF_IMG|>",
- end_of_img_token="<|END_OF_IMG|>",
- img_patch_token="<|IMG_PATCH|>",
- img_line_break_token="<|IMG_LINE_BREAK|>",
- tile_token="TILE",
- tile_global_token="TILE_GLOBAL",
- chat_template=None,
- **kwargs,
- ):
+ """
super().__init__(image_processor, tokenizer, chat_template=chat_template)
self.image_token = image_token
@@ -124,31 +115,14 @@ def _prompt_split_image(self, num_patches):
img_string += f"{self.end_of_img_token}"
return img_string
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]]] = None,
**kwargs: Unpack[AyaVisionProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to PreTrainedTokenizerFast's [`~PreTrainedTokenizerFast.__call__`] to encode the text.
- To prepare the vision inputs, this method forwards the `images` and `kwargs` arguments to
- GotOcr2ImageProcessor's [`~GotOcr2ImageProcessor.__call__`] if `images` is not `None`.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/bamba/modeling_bamba.py b/src/transformers/models/bamba/modeling_bamba.py
index 944d97fa342f..1f3f9504a875 100644
--- a/src/transformers/models/bamba/modeling_bamba.py
+++ b/src/transformers/models/bamba/modeling_bamba.py
@@ -54,17 +54,16 @@ class BambaFlashAttentionKwargs(TypedDict, total=False):
Keyword arguments for advanced Flash Attention, causal-conv1d, and mamba_ssm kernel usage.
Use cases include padding-free training and fewer `torch.compile` graph breaks.
- Attributes:
- cu_seq_lens_q (`torch.LongTensor`)
- Gets cumulative sequence length for query state.
- cu_seq_lens_k (`torch.LongTensor`)
- Gets cumulative sequence length for key state.
- max_length_q (`int`):
- Maximum sequence length for query state.
- max_length_k (`int`):
- Maximum sequence length for key state.
- seq_idx (`torch.IntTensor):
- Index of each packed sequence.
+ cu_seq_lens_q (`torch.LongTensor`):
+ Gets cumulative sequence length for query state.
+ cu_seq_lens_k (`torch.LongTensor`):
+ Gets cumulative sequence length for key state.
+ max_length_q (`int`):
+ Maximum sequence length for query state.
+ max_length_k (`int`):
+ Maximum sequence length for key state.
+ seq_idx (`torch.IntTensor`):
+ Index of each packed sequence.
"""
cu_seq_lens_q: torch.LongTensor
diff --git a/src/transformers/models/bamba/modular_bamba.py b/src/transformers/models/bamba/modular_bamba.py
index 593935be004d..1c15c916914a 100644
--- a/src/transformers/models/bamba/modular_bamba.py
+++ b/src/transformers/models/bamba/modular_bamba.py
@@ -63,17 +63,16 @@ class BambaFlashAttentionKwargs(TypedDict, total=False):
Keyword arguments for advanced Flash Attention, causal-conv1d, and mamba_ssm kernel usage.
Use cases include padding-free training and fewer `torch.compile` graph breaks.
- Attributes:
- cu_seq_lens_q (`torch.LongTensor`)
- Gets cumulative sequence length for query state.
- cu_seq_lens_k (`torch.LongTensor`)
- Gets cumulative sequence length for key state.
- max_length_q (`int`):
- Maximum sequence length for query state.
- max_length_k (`int`):
- Maximum sequence length for key state.
- seq_idx (`torch.IntTensor):
- Index of each packed sequence.
+ cu_seq_lens_q (`torch.LongTensor`):
+ Gets cumulative sequence length for query state.
+ cu_seq_lens_k (`torch.LongTensor`):
+ Gets cumulative sequence length for key state.
+ max_length_q (`int`):
+ Maximum sequence length for query state.
+ max_length_k (`int`):
+ Maximum sequence length for key state.
+ seq_idx (`torch.IntTensor`):
+ Index of each packed sequence.
"""
cu_seq_lens_q: torch.LongTensor
diff --git a/src/transformers/models/bark/processing_bark.py b/src/transformers/models/bark/processing_bark.py
index 8fa04d4ee032..d364f669e1f5 100644
--- a/src/transformers/models/bark/processing_bark.py
+++ b/src/transformers/models/bark/processing_bark.py
@@ -24,7 +24,7 @@
from ...feature_extraction_utils import BatchFeature
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
-from ...utils import logging
+from ...utils import auto_docstring, logging
from ...utils.hub import cached_file
from ..auto import AutoTokenizer
@@ -32,22 +32,8 @@
logger = logging.get_logger(__name__)
+@auto_docstring
class BarkProcessor(ProcessorMixin):
- r"""
- Constructs a Bark processor which wraps a text tokenizer and optional Bark voice presets into a single processor.
-
- Args:
- tokenizer ([`PreTrainedTokenizer`]):
- An instance of [`PreTrainedTokenizer`].
- speaker_embeddings (`dict[dict[str]]`, *optional*):
- Optional nested speaker embeddings dictionary. The first level contains voice preset names (e.g
- `"en_speaker_4"`). The second level contains `"semantic_prompt"`, `"coarse_prompt"` and `"fine_prompt"`
- embeddings. The values correspond to the path of the corresponding `np.ndarray`. See
- [here](https://suno-ai.notion.site/8b8e8749ed514b0cbf3f699013548683?v=bc67cff786b04b50b3ceb756fd05f68c) for
- a list of `voice_preset_names`.
-
- """
-
preset_shape = {
"semantic_prompt": 1, # 1D array of shape (X,)
"coarse_prompt": 2, # 2D array of shape (2,X)
@@ -55,6 +41,14 @@ class BarkProcessor(ProcessorMixin):
}
def __init__(self, tokenizer, speaker_embeddings=None):
+ r"""
+ speaker_embeddings (`dict[dict[str]]`, *optional*):
+ Optional nested speaker embeddings dictionary. The first level contains voice preset names (e.g
+ `"en_speaker_4"`). The second level contains `"semantic_prompt"`, `"coarse_prompt"` and `"fine_prompt"`
+ embeddings. The values correspond to the path of the corresponding `np.ndarray`. See
+ [here](https://suno-ai.notion.site/8b8e8749ed514b0cbf3f699013548683?v=bc67cff786b04b50b3ceb756fd05f68c) for
+ a list of `voice_preset_names`.
+ """
super().__init__(tokenizer)
self.speaker_embeddings = speaker_embeddings
@@ -259,6 +253,7 @@ def _verify_speaker_embeddings(self, remove_unavailable: bool = True):
for voice_preset in unavailable_keys:
del self.speaker_embeddings[voice_preset]
+ @auto_docstring
def __call__(
self,
text=None,
@@ -270,27 +265,12 @@ def __call__(
return_token_type_ids=False,
**kwargs,
) -> BatchEncoding:
- """
- Main method to prepare for the model one or several sequences(s). This method forwards the `text` and `kwargs`
- arguments to the AutoTokenizer's [`~AutoTokenizer.__call__`] to encode the text. The method also proposes a
- voice preset which is a dictionary of arrays that conditions `Bark`'s output. `kwargs` arguments are forwarded
- to the tokenizer and to `cached_file` method if `voice_preset` is a valid filename.
-
- Args:
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- voice_preset (`str`, `dict[np.ndarray]`):
- The voice preset, i.e the speaker embeddings. It can either be a valid voice_preset name, e.g
- `"en_speaker_1"`, or directly a dictionary of `np.ndarray` embeddings for each submodel of `Bark`. Or
- it can be a valid file name of a local `.npz` single voice preset containing the keys
- `"semantic_prompt"`, `"coarse_prompt"` and `"fine_prompt"`.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
-
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
+ r"""
+ voice_preset (`str`, `dict[np.ndarray]`):
+ The voice preset, i.e the speaker embeddings. It can either be a valid voice_preset name, e.g
+ `"en_speaker_1"`, or directly a dictionary of `np.ndarray` embeddings for each submodel of `Bark`. Or
+ it can be a valid file name of a local `.npz` single voice preset containing the keys
+ `"semantic_prompt"`, `"coarse_prompt"` and `"fine_prompt"`.
Returns:
[`BatchEncoding`]: A [`BatchEncoding`] object containing the output of the `tokenizer`.
diff --git a/src/transformers/models/blip/processing_blip.py b/src/transformers/models/blip/processing_blip.py
index 097b4f008ac6..30ef6c593572 100644
--- a/src/transformers/models/blip/processing_blip.py
+++ b/src/transformers/models/blip/processing_blip.py
@@ -20,6 +20,7 @@
from ...image_utils import ImageInput
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import BatchEncoding, PreTokenizedInput, TextInput
+from ...utils import auto_docstring
class BlipProcessorKwargs(ProcessingKwargs, total=False):
@@ -38,48 +39,19 @@ class BlipProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class BlipProcessor(ProcessorMixin):
- r"""
- Constructs a BLIP processor which wraps a BERT tokenizer and BLIP image processor into a single processor.
-
- [`BlipProcessor`] offers all the functionalities of [`BlipImageProcessor`] and [`BertTokenizerFast`]. See the
- docstring of [`~BlipProcessor.__call__`] and [`~BlipProcessor.decode`] for more information.
-
- Args:
- image_processor (`BlipImageProcessor`):
- An instance of [`BlipImageProcessor`]. The image processor is a required input.
- tokenizer (`BertTokenizerFast`):
- An instance of ['BertTokenizerFast`]. The tokenizer is a required input.
- """
-
def __init__(self, image_processor, tokenizer, **kwargs):
tokenizer.return_token_type_ids = False
super().__init__(image_processor, tokenizer)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[str, list[str], TextInput, PreTokenizedInput]] = None,
**kwargs: Unpack[BlipProcessorKwargs],
) -> BatchEncoding:
- """
- This method uses [`BlipImageProcessor.__call__`] method to prepare image(s) for the model, and
- [`BertTokenizerFast.__call__`] to prepare text for the model.
-
- Please refer to the docstring of the above two methods for more information.
- Args:
- images (`ImageInput`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`TextInput`, `PreTokenizedInput`, `list[TextInput]`, `list[PreTokenizedInput]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
- """
if images is None and text is None:
raise ValueError("You have to specify either images or text.")
diff --git a/src/transformers/models/blip_2/processing_blip_2.py b/src/transformers/models/blip_2/processing_blip_2.py
index 3b91304c73f0..e035637d8636 100644
--- a/src/transformers/models/blip_2/processing_blip_2.py
+++ b/src/transformers/models/blip_2/processing_blip_2.py
@@ -21,7 +21,7 @@
from ...image_utils import ImageInput
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import AddedToken, BatchEncoding, PreTokenizedInput, TextInput
-from ...utils import logging
+from ...utils import auto_docstring, logging
logger = logging.get_logger(__name__)
@@ -43,23 +43,13 @@ class Blip2ProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Blip2Processor(ProcessorMixin):
- r"""
- Constructs a BLIP-2 processor which wraps a BLIP image processor and an OPT/T5 tokenizer into a single processor.
-
- [`BlipProcessor`] offers all the functionalities of [`BlipImageProcessor`] and [`AutoTokenizer`]. See the docstring
- of [`~BlipProcessor.__call__`] and [`~BlipProcessor.decode`] for more information.
-
- Args:
- image_processor (`BlipImageProcessor`):
- An instance of [`BlipImageProcessor`]. The image processor is a required input.
- tokenizer (`AutoTokenizer`):
- An instance of ['PreTrainedTokenizer`]. The tokenizer is a required input.
+ def __init__(self, image_processor, tokenizer, num_query_tokens=None, **kwargs):
+ r"""
num_query_tokens (`int`, *optional*):
Number of tokens used by the Qformer as queries, should be same as in model's config.
- """
-
- def __init__(self, image_processor, tokenizer, num_query_tokens=None, **kwargs):
+ """
tokenizer.return_token_type_ids = False
if not hasattr(tokenizer, "image_token"):
self.image_token = AddedToken("", normalized=False, special=True)
@@ -70,30 +60,13 @@ def __init__(self, image_processor, tokenizer, num_query_tokens=None, **kwargs):
super().__init__(image_processor, tokenizer)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[str, list[str], TextInput, PreTokenizedInput]] = None,
**kwargs: Unpack[Blip2ProcessorKwargs],
) -> BatchEncoding:
- """
- This method uses [`BlipImageProcessor.__call__`] method to prepare image(s) for the model, and
- [`BertTokenizerFast.__call__`] to prepare text for the model.
-
- Please refer to the docstring of the above two methods for more information.
- Args:
- images (`ImageInput`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`TextInput`, `PreTokenizedInput`, `list[TextInput]`, `list[PreTokenizedInput]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
- """
if images is None and text is None:
raise ValueError("You have to specify either images or text.")
output_kwargs = self._merge_kwargs(
diff --git a/src/transformers/models/bridgetower/processing_bridgetower.py b/src/transformers/models/bridgetower/processing_bridgetower.py
index 0339573fa62d..aa0ea7b4c4da 100644
--- a/src/transformers/models/bridgetower/processing_bridgetower.py
+++ b/src/transformers/models/bridgetower/processing_bridgetower.py
@@ -16,6 +16,7 @@
"""
from ...processing_utils import ProcessingKwargs, ProcessorMixin
+from ...utils import auto_docstring
class BridgeTowerProcessorKwargs(ProcessingKwargs, total=False):
@@ -37,22 +38,8 @@ class BridgeTowerProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class BridgeTowerProcessor(ProcessorMixin):
- r"""
- Constructs a BridgeTower processor which wraps a Roberta tokenizer and BridgeTower image processor into a single
- processor.
-
- [`BridgeTowerProcessor`] offers all the functionalities of [`BridgeTowerImageProcessor`] and
- [`RobertaTokenizerFast`]. See the docstring of [`~BridgeTowerProcessor.__call__`] and
- [`~BridgeTowerProcessor.decode`] for more information.
-
- Args:
- image_processor (`BridgeTowerImageProcessor`):
- An instance of [`BridgeTowerImageProcessor`]. The image processor is a required input.
- tokenizer (`RobertaTokenizerFast`):
- An instance of ['RobertaTokenizerFast`]. The tokenizer is a required input.
- """
-
valid_processor_kwargs = BridgeTowerProcessorKwargs
def __init__(self, image_processor, tokenizer):
diff --git a/src/transformers/models/bros/processing_bros.py b/src/transformers/models/bros/processing_bros.py
index 4691834e6277..4cf108d1371d 100644
--- a/src/transformers/models/bros/processing_bros.py
+++ b/src/transformers/models/bros/processing_bros.py
@@ -16,6 +16,7 @@
"""
from ...processing_utils import ProcessingKwargs, ProcessorMixin
+from ...utils import auto_docstring
class BrosProcessorKwargs(ProcessingKwargs, total=False):
@@ -33,18 +34,8 @@ class BrosProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class BrosProcessor(ProcessorMixin):
- r"""
- Constructs a Bros processor which wraps a BERT tokenizer.
-
- [`BrosProcessor`] offers all the functionalities of [`BertTokenizerFast`]. See the docstring of
- [`~BrosProcessor.__call__`] and [`~BrosProcessor.decode`] for more information.
-
- Args:
- tokenizer (`BertTokenizerFast`, *optional*):
- An instance of ['BertTokenizerFast`]. The tokenizer is a required input.
- """
-
valid_processor_kwargs = BrosProcessorKwargs
def __init__(self, tokenizer=None, **kwargs):
diff --git a/src/transformers/models/chameleon/processing_chameleon.py b/src/transformers/models/chameleon/processing_chameleon.py
index df934cbfdf67..24b2b134be48 100644
--- a/src/transformers/models/chameleon/processing_chameleon.py
+++ b/src/transformers/models/chameleon/processing_chameleon.py
@@ -29,9 +29,17 @@
Unpack,
)
from ...tokenization_utils_base import PreTokenizedInput, TextInput
+from ...utils import auto_docstring
class ChameleonTextKwargs(TextKwargs, total=False):
+ """
+ return_for_text_completion (`bool`, *optional*, defaults to `False`):
+ Whether the processed text is intended for text completion tasks. When `True`, the processor does not
+ append the separator token (`sep_token`) to the end of the prompt, which is typically used for chat
+ mode. When `False`, the separator token is appended for proper chat formatting.
+ """
+
return_for_text_completion: bool
@@ -49,26 +57,15 @@ class ChameleonProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class ChameleonProcessor(ProcessorMixin):
- r"""
- Constructs a Chameleon processor which wraps a Chameleon image processor and a Chameleon tokenizer into a single
- processor.
-
- [`ChameleonProcessor`] offers all the functionalities of [`ChameleonImageProcessor`] and [`LlamaTokenizerFast`].
- See the [`~ChameleonProcessor.__call__`] and [`~ChameleonProcessor.decode`] for more information.
-
- Args:
- image_processor ([`ChameleonImageProcessor`]):
- The image processor is a required input.
- tokenizer ([`LlamaTokenizerFast`]):
- The tokenizer is a required input.
+ def __init__(self, image_processor, tokenizer, image_seq_length: int = 1024, image_token: str = ""):
+ r"""
image_seq_length (`int`, *optional*, defaults to 1024):
Sequence length of one image embedding.
image_token (`str`, *optional*, defaults to `""`):
The special token used to indicate image in the text.
- """
-
- def __init__(self, image_processor, tokenizer, image_seq_length: int = 1024, image_token: str = ""):
+ """
self.image_seq_length = image_seq_length
self.image_token = tokenizer.image_token if hasattr(tokenizer, "image_token") else image_token
self.image_token_id = tokenizer.convert_tokens_to_ids(self.image_token)
@@ -83,33 +80,14 @@ def __init__(self, image_processor, tokenizer, image_seq_length: int = 1024, ima
super().__init__(image_processor, tokenizer)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]]] = None,
**kwargs: Unpack[ChameleonProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to LlamaTokenizerFast's [`~LlamaTokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- CLIPImageProcessor's [`~CLIPImageProcessor.__call__`] if `images` is not `None`. Please refer to the docstring
- of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
-
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/chinese_clip/processing_chinese_clip.py b/src/transformers/models/chinese_clip/processing_chinese_clip.py
index c76008d5259b..71feda46e115 100644
--- a/src/transformers/models/chinese_clip/processing_chinese_clip.py
+++ b/src/transformers/models/chinese_clip/processing_chinese_clip.py
@@ -16,23 +16,11 @@
"""
from ...processing_utils import ProcessorMixin
+from ...utils import auto_docstring
+@auto_docstring
class ChineseCLIPProcessor(ProcessorMixin):
- r"""
- Constructs a Chinese-CLIP processor which wraps a Chinese-CLIP image processor and a Chinese-CLIP tokenizer into a
- single processor.
-
- [`ChineseCLIPProcessor`] offers all the functionalities of [`ChineseCLIPImageProcessor`] and [`BertTokenizerFast`].
- See the [`~ChineseCLIPProcessor.__call__`] and [`~ChineseCLIPProcessor.decode`] for more information.
-
- Args:
- image_processor ([`ChineseCLIPImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`BertTokenizerFast`], *optional*):
- The tokenizer is a required input.
- """
-
def __init__(self, image_processor=None, tokenizer=None, **kwargs):
super().__init__(image_processor, tokenizer)
diff --git a/src/transformers/models/clap/processing_clap.py b/src/transformers/models/clap/processing_clap.py
index e8178229a753..567aa19ce607 100644
--- a/src/transformers/models/clap/processing_clap.py
+++ b/src/transformers/models/clap/processing_clap.py
@@ -16,26 +16,14 @@
"""
from ...processing_utils import ProcessorMixin
-from ...utils import logging
+from ...utils import auto_docstring, logging
logger = logging.get_logger(__name__)
+@auto_docstring
class ClapProcessor(ProcessorMixin):
- r"""
- Constructs a CLAP processor which wraps a CLAP feature extractor and a RoBerta tokenizer into a single processor.
-
- [`ClapProcessor`] offers all the functionalities of [`ClapFeatureExtractor`] and [`RobertaTokenizerFast`]. See the
- [`~ClapProcessor.__call__`] and [`~ClapProcessor.decode`] for more information.
-
- Args:
- feature_extractor ([`ClapFeatureExtractor`]):
- The audio processor is a required input.
- tokenizer ([`RobertaTokenizerFast`]):
- The tokenizer is a required input.
- """
-
def __init__(self, feature_extractor, tokenizer):
super().__init__(feature_extractor, tokenizer)
diff --git a/src/transformers/models/clip/processing_clip.py b/src/transformers/models/clip/processing_clip.py
index d526c6d83294..f69b275c48b2 100644
--- a/src/transformers/models/clip/processing_clip.py
+++ b/src/transformers/models/clip/processing_clip.py
@@ -16,22 +16,11 @@
"""
from ...processing_utils import ProcessorMixin
+from ...utils import auto_docstring
+@auto_docstring
class CLIPProcessor(ProcessorMixin):
- r"""
- Constructs a CLIP processor which wraps a CLIP image processor and a CLIP tokenizer into a single processor.
-
- [`CLIPProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`CLIPTokenizerFast`]. See the
- [`~CLIPProcessor.__call__`] and [`~CLIPProcessor.decode`] for more information.
-
- Args:
- image_processor ([`CLIPImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`AutoTokenizer`], *optional*):
- The tokenizer is a required input.
- """
-
def __init__(self, image_processor=None, tokenizer=None, **kwargs):
super().__init__(image_processor, tokenizer)
diff --git a/src/transformers/models/clipseg/processing_clipseg.py b/src/transformers/models/clipseg/processing_clipseg.py
index a1d530e721a3..ad36ba4e14a2 100644
--- a/src/transformers/models/clipseg/processing_clipseg.py
+++ b/src/transformers/models/clipseg/processing_clipseg.py
@@ -17,51 +17,21 @@
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
+from ...utils import auto_docstring
+@auto_docstring
class CLIPSegProcessor(ProcessorMixin):
- r"""
- Constructs a CLIPSeg processor which wraps a CLIPSeg image processor and a CLIP tokenizer into a single processor.
-
- [`CLIPSegProcessor`] offers all the functionalities of [`ViTImageProcessor`] and [`CLIPTokenizerFast`]. See the
- [`~CLIPSegProcessor.__call__`] and [`~CLIPSegProcessor.decode`] for more information.
-
- Args:
- image_processor ([`ViTImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`CLIPTokenizerFast`], *optional*):
- The tokenizer is a required input.
- """
-
def __init__(self, image_processor=None, tokenizer=None, **kwargs):
super().__init__(image_processor, tokenizer)
+ @auto_docstring
def __call__(self, text=None, images=None, visual_prompt=None, return_tensors=None, **kwargs):
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to CLIPTokenizerFast's [`~CLIPTokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- ViTImageProcessor's [`~ViTImageProcessor.__call__`] if `images` is not `None`. Please refer to the docstring of
- the above two methods for more information.
-
- Args:
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- visual_prompt (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The visual prompt image or batch of images to be prepared. Each visual prompt image can be a PIL image,
- NumPy array or PyTorch tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape
- (C, H, W), where C is a number of channels, H and W are image height and width.
-
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
-
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
+ r"""
+ visual_prompt (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
+ The visual prompt image or batch of images to be prepared. Each visual prompt image can be a PIL image,
+ NumPy array or PyTorch tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape
+ (C, H, W), where C is a number of channels, H and W are image height and width.
Returns:
[`BatchEncoding`]: A [`BatchEncoding`] with the following fields:
diff --git a/src/transformers/models/clvp/processing_clvp.py b/src/transformers/models/clvp/processing_clvp.py
index 163e476f076a..2ca852653e6e 100644
--- a/src/transformers/models/clvp/processing_clvp.py
+++ b/src/transformers/models/clvp/processing_clvp.py
@@ -17,35 +17,19 @@
"""
from ...processing_utils import ProcessorMixin
-from ...utils import logging
+from ...utils import auto_docstring, logging
logger = logging.get_logger(__name__)
+@auto_docstring
class ClvpProcessor(ProcessorMixin):
- r"""
- Constructs a CLVP processor which wraps a CLVP Feature Extractor and a CLVP Tokenizer into a single processor.
-
- [`ClvpProcessor`] offers all the functionalities of [`ClvpFeatureExtractor`] and [`ClvpTokenizer`]. See the
- [`~ClvpProcessor.__call__`], [`~ClvpProcessor.decode`] and [`~ClvpProcessor.batch_decode`] for more information.
-
- Args:
- feature_extractor (`ClvpFeatureExtractor`):
- An instance of [`ClvpFeatureExtractor`]. The feature extractor is a required input.
- tokenizer (`ClvpTokenizer`):
- An instance of [`ClvpTokenizer`]. The tokenizer is a required input.
- """
-
def __init__(self, feature_extractor, tokenizer):
super().__init__(feature_extractor, tokenizer)
+ @auto_docstring
def __call__(self, *args, **kwargs):
- """
- Forwards the `audio` and `sampling_rate` arguments to [`~ClvpFeatureExtractor.__call__`] and the `text`
- argument to [`~ClvpTokenizer.__call__`]. Please refer to the docstring of the above two methods for more
- information.
- """
raw_speech = kwargs.pop("raw_speech", None)
if raw_speech is not None:
logger.warning(
diff --git a/src/transformers/models/cohere2_vision/processing_cohere2_vision.py b/src/transformers/models/cohere2_vision/processing_cohere2_vision.py
index 5b624c0226da..1c01da32dda0 100644
--- a/src/transformers/models/cohere2_vision/processing_cohere2_vision.py
+++ b/src/transformers/models/cohere2_vision/processing_cohere2_vision.py
@@ -20,6 +20,7 @@
from ...image_utils import ImageInput
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
+from ...utils import auto_docstring
class Cohere2VisionProcessorKwargs(ProcessingKwargs, total=False):
@@ -32,20 +33,8 @@ class Cohere2VisionProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Cohere2VisionProcessor(ProcessorMixin):
- r"""
- Constructs a Cohere2Vision processor which wraps a [`AutoImageProcessor`] and
- [`PretrainedTokenizerFast`] tokenizer into a single processor that inherits both the image processor and
- tokenizer functionalities. See the [`~Cohere2VisionProcessor.__call__`] and [`~Cohere2VisionProcessor.decode`] for more information.
- Args:
- image_processor ([`AutoImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`PreTrainedTokenizer`, `PreTrainedTokenizerFast`], *optional*):
- The tokenizer is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
def __init__(
self,
image_processor=None,
@@ -71,31 +60,14 @@ def __init__(
]
)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]]] = None,
**kwargs: Unpack[Cohere2VisionProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to PreTrainedTokenizerFast's [`~PreTrainedTokenizerFast.__call__`] to encode the text.
- To prepare the vision inputs, this method forwards the `images` and `kwargs` arguments to
- GotOcr2ImageProcessor's [`~GotOcr2ImageProcessor.__call__`] if `images` is not `None`.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/colpali/modular_colpali.py b/src/transformers/models/colpali/modular_colpali.py
index 2c335233e587..dec2fee64dea 100644
--- a/src/transformers/models/colpali/modular_colpali.py
+++ b/src/transformers/models/colpali/modular_colpali.py
@@ -44,26 +44,6 @@ class ColPaliProcessorKwargs(ProcessingKwargs, total=False):
class ColPaliProcessor(PaliGemmaProcessor):
- r"""
- Constructs a ColPali processor which wraps a PaliGemmaProcessor and special methods to process images and queries, as
- well as to compute the late-interaction retrieval score.
-
- [`ColPaliProcessor`] offers all the functionalities of [`PaliGemmaProcessor`]. See the [`~PaliGemmaProcessor.__call__`]
- for more information.
-
- Args:
- image_processor ([`SiglipImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`LlamaTokenizerFast`], *optional*):
- The tokenizer is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- visual_prompt_prefix (`str`, *optional*, defaults to `"Describe the image."`):
- A string that gets tokenized and prepended to the image tokens.
- query_prefix (`str`, *optional*, defaults to `"Question: "`):
- A prefix to be used for the query.
- """
-
def __init__(
self,
image_processor=None,
@@ -72,6 +52,12 @@ def __init__(
visual_prompt_prefix: str = "Describe the image.",
query_prefix: str = "Question: ",
):
+ r"""
+ visual_prompt_prefix (`str`, *optional*, defaults to `"Describe the image."`):
+ A string that gets tokenized and prepended to the image tokens.
+ query_prefix (`str`, *optional*, defaults to `"Question: "`):
+ A prefix to be used for the query.
+ """
self.visual_prompt_prefix = visual_prompt_prefix
self.query_prefix = query_prefix
super().__init__(image_processor=image_processor, tokenizer=tokenizer, chat_template=chat_template)
@@ -91,32 +77,7 @@ def __call__(
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
**kwargs: Unpack[ColPaliProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model either (1) one or several texts, either (2) one or several image(s). This method is a custom
- wrapper around the PaliGemmaProcessor's [`~PaliGemmaProcessor.__call__`] method adapted for the ColPali model. It cannot process
- both text and images at the same time.
-
- When preparing the text(s), this method forwards the `text` and `kwargs` arguments to LlamaTokenizerFast's
- [`~LlamaTokenizerFast.__call__`].
- When preparing the image(s), this method forwards the `images` and `kwargs` arguments to SiglipImageProcessor's
- [`~SiglipImageProcessor.__call__`].
- Please refer to the docstring of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape (C, H, W), where C is a
- number of channels, H and W are image height and width.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
-
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/colpali/processing_colpali.py b/src/transformers/models/colpali/processing_colpali.py
index 2bc9ca37e599..efdccaee4c1d 100644
--- a/src/transformers/models/colpali/processing_colpali.py
+++ b/src/transformers/models/colpali/processing_colpali.py
@@ -25,7 +25,7 @@
from ...image_utils import ImageInput, make_flat_list_of_images
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import AddedToken, PreTokenizedInput, TextInput
-from ...utils import is_torch_available
+from ...utils import auto_docstring, is_torch_available
if is_torch_available():
@@ -71,27 +71,8 @@ def build_string_from_input(prompt, bos_token, image_seq_len, image_token, num_i
return f"{image_token * image_seq_len * num_images}{bos_token}{prompt}\n"
+@auto_docstring
class ColPaliProcessor(ProcessorMixin):
- r"""
- Constructs a ColPali processor which wraps a PaliGemmaProcessor and special methods to process images and queries, as
- well as to compute the late-interaction retrieval score.
-
- [`ColPaliProcessor`] offers all the functionalities of [`PaliGemmaProcessor`]. See the [`~PaliGemmaProcessor.__call__`]
- for more information.
-
- Args:
- image_processor ([`SiglipImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`LlamaTokenizerFast`], *optional*):
- The tokenizer is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- visual_prompt_prefix (`str`, *optional*, defaults to `"Describe the image."`):
- A string that gets tokenized and prepended to the image tokens.
- query_prefix (`str`, *optional*, defaults to `"Question: "`):
- A prefix to be used for the query.
- """
-
def __init__(
self,
image_processor=None,
@@ -100,6 +81,12 @@ def __init__(
visual_prompt_prefix: str = "Describe the image.",
query_prefix: str = "Question: ",
):
+ r"""
+ visual_prompt_prefix (`str`, *optional*, defaults to `"Describe the image."`):
+ A string that gets tokenized and prepended to the image tokens.
+ query_prefix (`str`, *optional*, defaults to `"Question: "`):
+ A prefix to be used for the query.
+ """
self.visual_prompt_prefix = visual_prompt_prefix
self.query_prefix = query_prefix
if not hasattr(image_processor, "image_seq_length"):
@@ -123,38 +110,14 @@ def __init__(
super().__init__(image_processor, tokenizer, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
images: ImageInput | None = None,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
**kwargs: Unpack[ColPaliProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model either (1) one or several texts, either (2) one or several image(s). This method is a custom
- wrapper around the PaliGemmaProcessor's [`~PaliGemmaProcessor.__call__`] method adapted for the ColPali model. It cannot process
- both text and images at the same time.
-
- When preparing the text(s), this method forwards the `text` and `kwargs` arguments to LlamaTokenizerFast's
- [`~LlamaTokenizerFast.__call__`].
- When preparing the image(s), this method forwards the `images` and `kwargs` arguments to SiglipImageProcessor's
- [`~SiglipImageProcessor.__call__`].
- Please refer to the docstring of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape (C, H, W), where C is a
- number of channels, H and W are image height and width.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
-
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/colqwen2/modular_colqwen2.py b/src/transformers/models/colqwen2/modular_colqwen2.py
index 41fbb849a5e3..1e8b9712a46b 100644
--- a/src/transformers/models/colqwen2/modular_colqwen2.py
+++ b/src/transformers/models/colqwen2/modular_colqwen2.py
@@ -45,24 +45,6 @@ class ColQwen2ProcessorKwargs(ProcessingKwargs, total=False):
class ColQwen2Processor(ColPaliProcessor):
- r"""
- Constructs a ColQwen2 processor which wraps a Qwen2VLProcessor and special methods to process images and queries, as
- well as to compute the late-interaction retrieval score.
-
- [`ColQwen2Processor`] offers all the functionalities of [`Qwen2VLProcessor`]. See the [`~Qwen2VLProcessor.__call__`]
- for more information.
-
- Args:
- image_processor ([`Qwen2VLImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`Qwen2TokenizerFast`], *optional*):
- The tokenizer is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- visual_prompt_prefix (`str`, *optional*): A string that gets tokenized and prepended to the image tokens.
- query_prefix (`str`, *optional*): A prefix to be used for the query.
- """
-
def __init__(
self,
image_processor=None,
@@ -72,6 +54,12 @@ def __init__(
query_prefix: str | None = None,
**kwargs,
):
+ r"""
+ visual_prompt_prefix (`str`, *optional*, defaults to `"<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe the image.<|im_end|><|endoftext|>"`):
+ A string that gets tokenized and prepended to the image tokens.
+ query_prefix (`str`, *optional*, defaults to `"Query: "`):
+ A prefix to be used for the query.
+ """
ProcessorMixin.__init__(self, image_processor, tokenizer, chat_template=chat_template)
self.image_token = "<|image_pad|>" if not hasattr(tokenizer, "image_token") else tokenizer.image_token
self.video_token = "<|video_pad|>" if not hasattr(tokenizer, "video_token") else tokenizer.video_token
@@ -90,32 +78,7 @@ def __call__(
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
**kwargs: Unpack[ColQwen2ProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model either (1) one or several texts, either (2) one or several image(s). This method is a custom
- wrapper around the Qwen2VLProcessor's [`~Qwen2VLProcessor.__call__`] method adapted for the ColQwen2 model. It cannot process
- both text and images at the same time.
-
- When preparing the text(s), this method forwards the `text` and `kwargs` arguments to Qwen2TokenizerFast's
- [`~Qwen2TokenizerFast.__call__`].
- When preparing the image(s), this method forwards the `images` and `kwargs` arguments to Qwen2VLImageProcessor's
- [`~Qwen2VLImageProcessor.__call__`].
- Please refer to the doctsring of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape (C, H, W), where C is a
- number of channels, H and W are image height and width.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
-
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/colqwen2/processing_colqwen2.py b/src/transformers/models/colqwen2/processing_colqwen2.py
index 9682284dd778..9f08c92efe69 100644
--- a/src/transformers/models/colqwen2/processing_colqwen2.py
+++ b/src/transformers/models/colqwen2/processing_colqwen2.py
@@ -24,7 +24,7 @@
from ...image_utils import ImageInput, is_valid_image
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import is_torch_available
+from ...utils import auto_docstring, is_torch_available
if is_torch_available():
@@ -44,25 +44,8 @@ class ColQwen2ProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class ColQwen2Processor(ProcessorMixin):
- r"""
- Constructs a ColQwen2 processor which wraps a Qwen2VLProcessor and special methods to process images and queries, as
- well as to compute the late-interaction retrieval score.
-
- [`ColQwen2Processor`] offers all the functionalities of [`Qwen2VLProcessor`]. See the [`~Qwen2VLProcessor.__call__`]
- for more information.
-
- Args:
- image_processor ([`Qwen2VLImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`Qwen2TokenizerFast`], *optional*):
- The tokenizer is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- visual_prompt_prefix (`str`, *optional*): A string that gets tokenized and prepended to the image tokens.
- query_prefix (`str`, *optional*): A prefix to be used for the query.
- """
-
def __init__(
self,
image_processor=None,
@@ -72,6 +55,12 @@ def __init__(
query_prefix: str | None = None,
**kwargs,
):
+ r"""
+ visual_prompt_prefix (`str`, *optional*, defaults to `"<|im_start|>user\n<|vision_start|><|image_pad|><|vision_end|>Describe the image.<|im_end|><|endoftext|>"`):
+ A string that gets tokenized and prepended to the image tokens.
+ query_prefix (`str`, *optional*, defaults to `"Query: "`):
+ A prefix to be used for the query.
+ """
super().__init__(image_processor, tokenizer, chat_template=chat_template)
self.image_token = "<|image_pad|>" if not hasattr(tokenizer, "image_token") else tokenizer.image_token
self.video_token = "<|video_pad|>" if not hasattr(tokenizer, "video_token") else tokenizer.video_token
@@ -84,38 +73,14 @@ def __init__(
query_prefix = "Query: "
self.query_prefix = query_prefix
+ @auto_docstring
def __call__(
self,
images: ImageInput | None = None,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
**kwargs: Unpack[ColQwen2ProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model either (1) one or several texts, either (2) one or several image(s). This method is a custom
- wrapper around the Qwen2VLProcessor's [`~Qwen2VLProcessor.__call__`] method adapted for the ColQwen2 model. It cannot process
- both text and images at the same time.
-
- When preparing the text(s), this method forwards the `text` and `kwargs` arguments to Qwen2TokenizerFast's
- [`~Qwen2TokenizerFast.__call__`].
- When preparing the image(s), this method forwards the `images` and `kwargs` arguments to Qwen2VLImageProcessor's
- [`~Qwen2VLImageProcessor.__call__`].
- Please refer to the doctsring of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. In case of a NumPy array/PyTorch tensor, each image should be of shape (C, H, W), where C is a
- number of channels, H and W are image height and width.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
-
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/csm/processing_csm.py b/src/transformers/models/csm/processing_csm.py
index 8d0c1e55efe8..7e5707ee4c29 100644
--- a/src/transformers/models/csm/processing_csm.py
+++ b/src/transformers/models/csm/processing_csm.py
@@ -18,7 +18,7 @@
import numpy as np
-from ...utils import is_soundfile_available, is_torch_available
+from ...utils import auto_docstring, is_soundfile_available, is_torch_available
if is_torch_available():
@@ -34,6 +34,14 @@
class CsmAudioKwargs(AudioKwargs, total=False):
+ """
+ encoded_length_kwargs (`dict[str, Any]`, *optional*):
+ Dictionary of keyword arguments used to compute the encoded audio sequence length. This includes parameters
+ such as `kernel_sizes`, `strides`, `dilations`, and `use_causal_conv` that define the convolutional layers
+ used in audio encoding. The encoded length is used to determine how many audio tokens to generate for each
+ audio input in the text sequence.
+ """
+
encoded_length_kwargs: Optional[dict[str, Any]]
@@ -58,42 +66,8 @@ class CsmProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class CsmProcessor(ProcessorMixin):
- r"""
- Constructs a Csm processor which wraps [`EncodecFeatureExtractor`] and
- [`PretrainedTokenizerFast`] into a single processor that inherits both the audio feature extraction and
- tokenizer functionalities. See the [`~CsmProcessor.__call__`] for more
- information.
- The preferred way of passing kwargs is as a dictionary per modality, see usage example below.
- ```python
- from transformers import CsmProcessor
- from datasets import load_dataset
-
- ds = load_dataset("hf-internal-testing/dailytalk-dummy", split="train")
- audio = ds[0]["audio"]["array"]
-
- processor = CsmProcessor.from_pretrained("sesame/csm-1b")
-
- processor(
- text=["<|begin_of_text|>[0]What are you working on?<|end_of_text|><|AUDIO|><|audio_eos|><|begin_of_text|>[1]I'm figuring out my budget.<|end_of_text|>"],
- audio=audio,
- text_kwargs = {"padding": False},
- audio_kwargs = {"sampling_rate": 16000},
- common_kwargs = {"return_tensors": "pt"},
- )
- # this should error out because EncodecFeatureExtractor expects a 24kHz audio :)
- ```
-
- Args:
- feature_extractor ([`EncodecFeatureExtractor`]):
- The feature extractor is a required input.
- tokenizer ([`PreTrainedTokenizer`, `PreTrainedTokenizerFast`]):
- The tokenizer is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
-
- """
-
def __init__(
self,
feature_extractor,
@@ -188,6 +162,7 @@ def save_audio(
audio_value = audio_value.cpu().float().numpy()
sf.write(p, audio_value, sampling_rate)
+ @auto_docstring
def __call__(
self,
text: Optional[Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]]],
@@ -197,31 +172,14 @@ def __call__(
**kwargs: Unpack[CsmProcessorKwargs],
):
r"""
- Main method to prepare text(s) and audio to be fed as input to the model. This method forwards the `text`
- arguments to PreTrainedTokenizerFast's [`~PreTrainedTokenizerFast.__call__`] to encode
- the text. To prepare the audio, this method forwards the `audio` arguments to
- EncodecFeatureExtractor's [`~EncodecFeatureExtractor.__call__`]. Please refer
- to the docstring of the above two methods for more information.
+ output_labels (bool, *optional*, default=False):
+ Whether to return labels for training. Indices will be in `[config.audio_token_id, -100, -101]`.
+ - `config.audio_token_id` indicates an audio frame (considering sequence length elements as frames)
+ - `-100` will be ignored in the loss computation
+ - `-101` indicates the audio frame will be used only for the backbone model (using the first codebook token as labels)
+ depth_decoder_labels_ratio (float, *optional*, default=1.0):
+ The ratio of audio frames to keep for the depth decoder labels.
- Args:
- audio (`np.ndarray`, `torch.Tensor`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The audio or batch of audio to be prepared. Each audio can be a NumPy array or PyTorch
- tensor.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- output_labels (bool, *optional*, default=False):
- Whether to return labels for training. Indices will be in `[config.audio_token_id, -100, -101]`.
- - `config.audio_token_id` indicates an audio frame (considering sequence length elements as frames)
- - `-100` will be ignored in the loss computation
- - `-101` indicates the audio frame will be used only for the backbone model (using the first codebook token as labels)
- depth_decoder_labels_ratio (float, *optional*, default=1.0):
- The ratio of audio frames to keep for the depth decoder labels.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/data2vec/modeling_data2vec_audio.py b/src/transformers/models/data2vec/modeling_data2vec_audio.py
index f85f2fa9fbe1..5c1225e93db8 100755
--- a/src/transformers/models/data2vec/modeling_data2vec_audio.py
+++ b/src/transformers/models/data2vec/modeling_data2vec_audio.py
@@ -812,10 +812,10 @@ def forward(
class Data2VecAudioForCTC(Data2VecAudioPreTrainedModel):
def __init__(self, config):
r"""
- target_lang (`str`, *optional*):
- Language id of adapter weights. Adapter weights are stored in the format adapter..safetensors or
- adapter..bin. Only relevant when using an instance of [`Data2VecAudioForCTC`] with adapters. Uses 'eng' by
- default.
+ config ([`Data2VecAudioForCTC`]):
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
+ load the weights associated with the model, only the configuration. Check out the
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
"""
super().__init__(config)
diff --git a/src/transformers/models/data2vec/modular_data2vec_audio.py b/src/transformers/models/data2vec/modular_data2vec_audio.py
index 997dc3ab6a79..a6f5dda725da 100644
--- a/src/transformers/models/data2vec/modular_data2vec_audio.py
+++ b/src/transformers/models/data2vec/modular_data2vec_audio.py
@@ -214,6 +214,12 @@ def forward(self, **super_kwargs):
class Data2VecAudioForCTC(Data2VecAudioPreTrainedModel, Wav2Vec2ForCTC):
def __init__(self, config):
+ r"""
+ config ([`Data2VecAudioForCTC`]):
+ Model configuration class with all the parameters of the model. Initializing with a config file does not
+ load the weights associated with the model, only the configuration. Check out the
+ [`~PreTrainedModel.from_pretrained`] method to load the model weights.
+ """
Data2VecAudioPreTrainedModel.__init__(self, config)
self.data2vec_audio = Data2VecAudioModel(config)
diff --git a/src/transformers/models/deepseek_vl/modular_deepseek_vl.py b/src/transformers/models/deepseek_vl/modular_deepseek_vl.py
index 127f2d6d78df..23c3ed23c0d3 100644
--- a/src/transformers/models/deepseek_vl/modular_deepseek_vl.py
+++ b/src/transformers/models/deepseek_vl/modular_deepseek_vl.py
@@ -197,25 +197,8 @@ class DeepseekVLProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class DeepseekVLProcessor(ProcessorMixin):
- r"""
- Constructs a DeepseekVL processor which wraps a DeepseekVL Image Processor and a Llama tokenizer into a single processor.
-
- [`DeepseekVLProcessor`] offers all the functionalities of [`DeepseekVLImageProcessor`] and [`LlamaTokenizerFast`]. See the
- [`~DeepseekVLProcessor.__call__`] and [`~DeepseekVLProcessor.decode`] for more information.
-
- Args:
- image_processor ([`DeepseekVLImageProcessor`]):
- The image processor is a required input.
- tokenizer ([`LlamaTokenizerFast`]):
- The tokenizer is a required input.
- chat_template (`str`, *optional*):
- A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- num_image_tokens (`int`, *optional*, defaults to 576):
- The number of special image tokens used as placeholders for visual content in text sequences.
- """
-
def __init__(
self,
image_processor,
@@ -223,37 +206,23 @@ def __init__(
chat_template=None,
num_image_tokens=576,
):
+ r"""
+ num_image_tokens (`int`, *optional*, defaults to 576):
+ The number of special image tokens used as placeholders for visual content in text sequences.
+ """
self.image_token = tokenizer.image_token
self.num_image_tokens = num_image_tokens
super().__init__(image_processor, tokenizer, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
images: ImageInput | None = None,
**kwargs: Unpack[DeepseekVLProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to LlamaTokenizerFast's [`~LlamaTokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- DeepseekVLImageProcessor's [`~DeepseekVLImageProcessor.__call__`] if `images` is not `None`. Please refer to the doctsring
- of the above two methods for more information.
-
- Args:
- text (`str`, `List[str]`, `List[List[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/deepseek_vl/processing_deepseek_vl.py b/src/transformers/models/deepseek_vl/processing_deepseek_vl.py
index 7c7bed8d02d3..7057ff152a67 100644
--- a/src/transformers/models/deepseek_vl/processing_deepseek_vl.py
+++ b/src/transformers/models/deepseek_vl/processing_deepseek_vl.py
@@ -23,6 +23,7 @@
from ...image_utils import ImageInput
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
+from ...utils import auto_docstring
class DeepseekVLProcessorKwargs(ProcessingKwargs, total=False):
@@ -32,25 +33,8 @@ class DeepseekVLProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class DeepseekVLProcessor(ProcessorMixin):
- r"""
- Constructs a DeepseekVL processor which wraps a DeepseekVL Image Processor and a Llama tokenizer into a single processor.
-
- [`DeepseekVLProcessor`] offers all the functionalities of [`DeepseekVLImageProcessor`] and [`LlamaTokenizerFast`]. See the
- [`~DeepseekVLProcessor.__call__`] and [`~DeepseekVLProcessor.decode`] for more information.
-
- Args:
- image_processor ([`DeepseekVLImageProcessor`]):
- The image processor is a required input.
- tokenizer ([`LlamaTokenizerFast`]):
- The tokenizer is a required input.
- chat_template (`str`, *optional*):
- A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- num_image_tokens (`int`, *optional*, defaults to 576):
- The number of special image tokens used as placeholders for visual content in text sequences.
- """
-
def __init__(
self,
image_processor,
@@ -58,37 +42,23 @@ def __init__(
chat_template=None,
num_image_tokens=576,
):
+ r"""
+ num_image_tokens (`int`, *optional*, defaults to 576):
+ The number of special image tokens used as placeholders for visual content in text sequences.
+ """
self.image_token = tokenizer.image_token
self.num_image_tokens = num_image_tokens
super().__init__(image_processor, tokenizer, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
images: ImageInput | None = None,
**kwargs: Unpack[DeepseekVLProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to LlamaTokenizerFast's [`~LlamaTokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- DeepseekVLImageProcessor's [`~DeepseekVLImageProcessor.__call__`] if `images` is not `None`. Please refer to the doctsring
- of the above two methods for more information.
-
- Args:
- text (`str`, `List[str]`, `List[List[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/deepseek_vl_hybrid/modular_deepseek_vl_hybrid.py b/src/transformers/models/deepseek_vl_hybrid/modular_deepseek_vl_hybrid.py
index 2e46172c39a4..e85da0ad2e71 100644
--- a/src/transformers/models/deepseek_vl_hybrid/modular_deepseek_vl_hybrid.py
+++ b/src/transformers/models/deepseek_vl_hybrid/modular_deepseek_vl_hybrid.py
@@ -933,33 +933,14 @@ def __call__(
images: ImageInput | None = None,
**kwargs: Unpack[DeepseekVLHybridProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to LlamaTokenizerFast's [`~LlamaTokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- DeepseekVLHybridImageProcessor's [`~DeepseekVLHybridImageProcessor.__call__`] if `images` is not `None`. Please refer to the doctsring
- of the above two methods for more information.
-
- Args:
- text (`str`, `List[str]`, `List[List[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
- **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`.
- **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
- `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
- `None`).
+ `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
+ `None`).
- **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is not `None`.
"""
output_kwargs = self._merge_kwargs(
diff --git a/src/transformers/models/deepseek_vl_hybrid/processing_deepseek_vl_hybrid.py b/src/transformers/models/deepseek_vl_hybrid/processing_deepseek_vl_hybrid.py
index f94b4f0845f5..73309c4cbbf5 100644
--- a/src/transformers/models/deepseek_vl_hybrid/processing_deepseek_vl_hybrid.py
+++ b/src/transformers/models/deepseek_vl_hybrid/processing_deepseek_vl_hybrid.py
@@ -22,6 +22,7 @@
from ...image_utils import ImageInput
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
+from ...utils import auto_docstring
class DeepseekVLHybridProcessorKwargs(ProcessingKwargs, total=False):
@@ -31,25 +32,8 @@ class DeepseekVLHybridProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class DeepseekVLHybridProcessor(ProcessorMixin):
- r"""
- Constructs a DeepseekVLHybrid processor which wraps a DeepseekVLHybrid Image Processor and a Llama tokenizer into a single processor.
-
- [`DeepseekVLHybridProcessor`] offers all the functionalities of [`DeepseekVLHybridImageProcessor`] and [`LlamaTokenizerFast`]. See the
- [`~DeepseekVLHybridProcessor.__call__`] and [`~DeepseekVLHybridProcessor.decode`] for more information.
-
- Args:
- image_processor ([`DeepseekVLHybridImageProcessor`]):
- The image processor is a required input.
- tokenizer ([`LlamaTokenizerFast`]):
- The tokenizer is a required input.
- chat_template (`str`, *optional*):
- A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- num_image_tokens (`int`, *optional*, defaults to 576):
- The number of special image tokens used as placeholders for visual content in text sequences.
- """
-
def __init__(
self,
image_processor,
@@ -57,44 +41,30 @@ def __init__(
chat_template=None,
num_image_tokens=576,
):
+ r"""
+ num_image_tokens (`int`, *optional*, defaults to 576):
+ The number of special image tokens used as placeholders for visual content in text sequences.
+ """
self.image_token = tokenizer.image_token
self.num_image_tokens = num_image_tokens
super().__init__(image_processor, tokenizer, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
images: ImageInput | None = None,
**kwargs: Unpack[DeepseekVLHybridProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to LlamaTokenizerFast's [`~LlamaTokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- DeepseekVLHybridImageProcessor's [`~DeepseekVLHybridImageProcessor.__call__`] if `images` is not `None`. Please refer to the doctsring
- of the above two methods for more information.
-
- Args:
- text (`str`, `List[str]`, `List[List[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
- **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`.
- **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
- `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
- `None`).
+ `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
+ `None`).
- **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is not `None`.
"""
output_kwargs = self._merge_kwargs(
diff --git a/src/transformers/models/dia/processing_dia.py b/src/transformers/models/dia/processing_dia.py
index 0271ea547ac9..b9b78a1ab117 100644
--- a/src/transformers/models/dia/processing_dia.py
+++ b/src/transformers/models/dia/processing_dia.py
@@ -20,7 +20,7 @@
from ...audio_utils import AudioInput, make_list_of_audio
from ...feature_extraction_utils import BatchFeature
from ...processing_utils import AudioKwargs, ProcessingKwargs, ProcessorMixin, Unpack
-from ...utils import is_soundfile_available, is_torch_available
+from ...utils import auto_docstring, is_soundfile_available, is_torch_available
if is_torch_available():
@@ -31,6 +31,26 @@
class DiaAudioKwargs(AudioKwargs, total=False):
+ """
+ bos_token_id (`int`, *optional*, defaults to `1026`):
+ The token ID used as the beginning-of-sequence token for audio codebooks. This token is prepended to each
+ audio sequence during encoding.
+ eos_token_id (`int`, *optional*, defaults to `1024`):
+ The token ID used as the end-of-sequence token for audio codebooks. This token is appended to audio sequences
+ during training (when `generation=False`) to mark the end of the audio.
+ pad_token_id (`int`, *optional*, defaults to `1025`):
+ The token ID used for padding audio codebook sequences. This token is used to fill positions in the delay
+ pattern where no valid audio token exists.
+ delay_pattern (`list[int]`, *optional*, defaults to `[0, 8, 9, 10, 11, 12, 13, 14, 15]`):
+ A list of delay values (in frames) for each codebook channel. The delay pattern creates temporal offsets
+ between different codebook channels, allowing the model to capture dependencies across channels. Each value
+ represents the number of frames to delay that specific channel.
+ generation (`bool`, *optional*, defaults to `True`):
+ Whether the processor is being used for generation (text-to-speech) or training. When `True`, the processor
+ prepares inputs for generation mode where audio is generated from text. When `False`, it prepares inputs for
+ training where both text and audio are provided.
+ """
+
bos_token_id: int
eos_token_id: int
pad_token_id: int
@@ -60,27 +80,18 @@ class DiaProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class DiaProcessor(ProcessorMixin):
- r"""
- Constructs a Dia processor which wraps a [`DiaFeatureExtractor`], [`DiaTokenizer`], and a [`DacModel`] into
- a single processor. It inherits, the audio feature extraction, tokenizer, and audio encode/decode functio-
- nalities. See [`~DiaProcessor.__call__`], [`~DiaProcessor.encode`], and [`~DiaProcessor.decode`] for more
- information.
-
- Args:
- feature_extractor (`DiaFeatureExtractor`):
- An instance of [`DiaFeatureExtractor`]. The feature extractor is a required input.
- tokenizer (`DiaTokenizer`):
- An instance of [`DiaTokenizer`]. The tokenizer is a required input.
- audio_tokenizer (`DacModel`):
- An instance of [`DacModel`] used to encode/decode audio into/from codebooks. It is a required input.
- """
-
audio_tokenizer_class = "DacModel"
def __init__(self, feature_extractor, tokenizer, audio_tokenizer):
+ r"""
+ audio_tokenizer (`DacModel`):
+ An instance of [`DacModel`] used to encode/decode audio into/from codebooks. It is is a required input.
+ """
super().__init__(feature_extractor, tokenizer, audio_tokenizer=audio_tokenizer)
+ @auto_docstring
def __call__(
self,
text: Union[str, list[str]],
@@ -88,11 +99,12 @@ def __call__(
output_labels: Optional[bool] = False,
**kwargs: Unpack[DiaProcessorKwargs],
):
- """
- Main method to prepare text(s) and audio to be fed as input to the model. The `audio` argument is
- forwarded to the DiaFeatureExtractor's [`~DiaFeatureExtractor.__call__`] and subsequently to the
- DacModel's [`~DacModel.encode`]. The `text` argument to [`~DiaTokenizer.__call__`]. Please refer
- to the docstring of the above methods for more information.
+ r"""
+ output_labels (`bool`, *optional*, defaults to `False`):
+ Whether to return labels for training. When `True`, the processor generates labels from the decoder input
+ sequence by shifting it by one position. Labels use special values: `-100` for tokens to ignore in loss
+ computation (padding and BOS tokens), and `-101` for audio frames used only for the backbone model (when
+ `depth_decoder_labels_ratio < 1.0`). Cannot be used together with `generation=True`.
"""
if not is_torch_available():
raise ValueError(
diff --git a/src/transformers/models/donut/processing_donut.py b/src/transformers/models/donut/processing_donut.py
index cbec09eddc57..e9cf463f21c9 100644
--- a/src/transformers/models/donut/processing_donut.py
+++ b/src/transformers/models/donut/processing_donut.py
@@ -21,7 +21,7 @@
from ...image_utils import ImageInput
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import logging
+from ...utils import auto_docstring, logging
class DonutProcessorKwargs(ProcessingKwargs, total=False):
@@ -31,37 +31,18 @@ class DonutProcessorKwargs(ProcessingKwargs, total=False):
logger = logging.get_logger(__name__)
+@auto_docstring
class DonutProcessor(ProcessorMixin):
- r"""
- Constructs a Donut processor which wraps a Donut image processor and an XLMRoBERTa tokenizer into a single
- processor.
-
- [`DonutProcessor`] offers all the functionalities of [`DonutImageProcessor`] and
- [`XLMRobertaTokenizer`/`XLMRobertaTokenizerFast`]. See the [`~DonutProcessor.__call__`] and
- [`~DonutProcessor.decode`] for more information.
-
- Args:
- image_processor ([`DonutImageProcessor`], *optional*):
- An instance of [`DonutImageProcessor`]. The image processor is a required input.
- tokenizer ([`XLMRobertaTokenizer`/`XLMRobertaTokenizerFast`], *optional*):
- An instance of [`XLMRobertaTokenizer`/`XLMRobertaTokenizerFast`]. The tokenizer is a required input.
- """
-
def __init__(self, image_processor=None, tokenizer=None, **kwargs):
super().__init__(image_processor, tokenizer)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[str, list[str], TextInput, PreTokenizedInput]] = None,
**kwargs: Unpack[DonutProcessorKwargs],
):
- """
- When used in normal mode, this method forwards all its arguments to AutoImageProcessor's
- [`~AutoImageProcessor.__call__`] and returns its output. If used in the context
- [`~DonutProcessor.as_target_processor`] this method forwards all its arguments to DonutTokenizer's
- [`~DonutTokenizer.__call__`]. Please refer to the docstring of the above two methods for more information.
- """
if images is None and text is None:
raise ValueError("You need to specify either an `images` or `text` input to process.")
diff --git a/src/transformers/models/emu3/image_processing_emu3.py b/src/transformers/models/emu3/image_processing_emu3.py
index 2a364b2e0289..bfe2a75799da 100644
--- a/src/transformers/models/emu3/image_processing_emu3.py
+++ b/src/transformers/models/emu3/image_processing_emu3.py
@@ -47,6 +47,13 @@
class Emu3ImageProcessorKwargs(ImagesKwargs, total=False):
+ """
+ ratio (`str`, *optional*, defaults to `"1:1"`):
+ The ratio of the image to resize the image.
+ image_area (`int`, *optional*, defaults to `518400`):
+ The area of the image to resize the image.
+ """
+
ratio: str
image_area: int
diff --git a/src/transformers/models/emu3/processing_emu3.py b/src/transformers/models/emu3/processing_emu3.py
index a807c19d9f54..e90a15eff3be 100644
--- a/src/transformers/models/emu3/processing_emu3.py
+++ b/src/transformers/models/emu3/processing_emu3.py
@@ -21,19 +21,29 @@
from ...image_utils import ImageInput
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import is_vision_available
+from ...utils import auto_docstring, is_vision_available
+from ...utils.import_utils import requires
if is_vision_available():
- from .image_processing_emu3 import smart_resize
+ from .image_processing_emu3 import Emu3ImageProcessorKwargs, smart_resize
class Emu3TextKwargs(TextKwargs, total=False):
+ """
+ return_for_image_generation (`bool`, *optional*, defaults to `False`):
+ Whether the processed text is intended for image generation tasks. When `True`, the processor prepares
+ inputs for image generation by appending image start tokens and size information to the prompt, and
+ images should not be provided. When `False`, the processor prepares inputs for text generation from
+ images and text, requiring both inputs to be provided.
+ """
+
return_for_image_generation: bool
class Emu3ProcessorKwargs(ProcessingKwargs, total=False):
text_kwargs: Emu3TextKwargs
+ images_kwargs: Emu3ImageProcessorKwargs
_defaults = {
"text_kwargs": {
"return_for_image_generation": False,
@@ -46,23 +56,9 @@ class Emu3ProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
+@requires(backends=("vision",))
class Emu3Processor(ProcessorMixin):
- r"""
- Constructs a Emu3 processor which wraps a Emu3 image processor and a GPT2 tokenizer into a single
- processor.
-
- [`Emu3Processor`] offers all the functionalities of [`Emu3ImageProcessor`] and [`GPT2TokenizerFast`].
- See the [`~Emu3Processor.__call__`] and [`~Emu3Processor.decode`] for more information.
-
- Args:
- image_processor ([`Emu3ImageProcessor`]):
- The image processor is a required input.
- tokenizer ([`Emu3TokenizerFast`]):
- The tokenizer is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
def __init__(
self,
image_processor,
@@ -80,33 +76,14 @@ def __init__(
self.downsample_ratio = 8
super().__init__(image_processor, tokenizer, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]]] = None,
**kwargs: Unpack[Emu3ProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to Emu3TokenizerFast's [`~Emu3TokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- CLIPImageProcessor's [`~CLIPImageProcessor.__call__`] if `images` is not `None`. Please refer to the docstring
- of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
-
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/evolla/processing_evolla.py b/src/transformers/models/evolla/processing_evolla.py
index ad80963a8347..70de5e4d640a 100644
--- a/src/transformers/models/evolla/processing_evolla.py
+++ b/src/transformers/models/evolla/processing_evolla.py
@@ -21,30 +21,23 @@
from ...processing_utils import (
ProcessorMixin,
)
+from ...utils import auto_docstring
PROTEIN_VALID_KEYS = ["aa_seq", "foldseek", "msa"]
+@auto_docstring
class EvollaProcessor(ProcessorMixin):
- r"""
- Constructs a EVOLLA processor which wraps a LLama tokenizer and SaProt tokenizer (EsmTokenizer) into a single processor.
-
- [`EvollaProcessor`] offers all the functionalities of [`EsmTokenizer`] and [`LlamaTokenizerFast`]. See the
- docstring of [`~EvollaProcessor.__call__`] and [`~EvollaProcessor.decode`] for more information.
-
- Args:
+ def __init__(self, protein_tokenizer, tokenizer=None, protein_max_length=1024, text_max_length=512, **kwargs):
+ r"""
protein_tokenizer (`EsmTokenizer`):
An instance of [`EsmTokenizer`]. The protein tokenizer is a required input.
- tokenizer (`LlamaTokenizerFast`, *optional*):
- An instance of [`LlamaTokenizerFast`]. The tokenizer is a required input.
protein_max_length (`int`, *optional*, defaults to 1024):
The maximum length of the sequence to be generated.
text_max_length (`int`, *optional*, defaults to 512):
The maximum length of the text to be generated.
- """
-
- def __init__(self, protein_tokenizer, tokenizer=None, protein_max_length=1024, text_max_length=512, **kwargs):
+ """
if protein_tokenizer is None:
raise ValueError("You need to specify an `protein_tokenizer`.")
if tokenizer is None:
@@ -93,6 +86,7 @@ def process_text(
)
return prompt_inputs
+ @auto_docstring
def __call__(
self,
proteins: Optional[Union[list[dict], dict]] = None,
@@ -101,22 +95,19 @@ def __call__(
text_max_length: Optional[int] = None,
**kwargs,
):
- r"""This method takes batched or non-batched proteins and messages_list and converts them into format that can be used by
- the model.
-
- Args:
- proteins (`Union[List[dict], dict]`):
- A list of dictionaries or a single dictionary containing the following keys:
- - `"aa_seq"` (`str`) -- The amino acid sequence of the protein.
- - `"foldseek"` (`str`) -- The foldseek string of the protein.
- messages_list (`Union[List[List[dict]], List[dict]]`):
- A list of lists of dictionaries or a list of dictionaries containing the following keys:
- - `"role"` (`str`) -- The role of the message.
- - `"content"` (`str`) -- The content of the message.
- protein_max_length (`int`, *optional*, defaults to 1024):
- The maximum length of the sequence to be generated.
- text_max_length (`int`, *optional*, defaults to 512):
- The maximum length of the text.
+ r"""
+ proteins (`Union[List[dict], dict]`):
+ A list of dictionaries or a single dictionary containing the following keys:
+ - `"aa_seq"` (`str`) -- The amino acid sequence of the protein.
+ - `"foldseek"` (`str`) -- The foldseek string of the protein.
+ messages_list (`Union[List[List[dict]], List[dict]]`):
+ A list of lists of dictionaries or a list of dictionaries containing the following keys:
+ - `"role"` (`str`) -- The role of the message.
+ - `"content"` (`str`) -- The content of the message.
+ protein_max_length (`int`, *optional*, defaults to 1024):
+ The maximum length of the sequence to be generated.
+ text_max_length (`int`, *optional*, defaults to 512):
+ The maximum length of the text.
Return:
a dict with following keys:
diff --git a/src/transformers/models/flava/processing_flava.py b/src/transformers/models/flava/processing_flava.py
index ee50475ee76b..592654a18f0e 100644
--- a/src/transformers/models/flava/processing_flava.py
+++ b/src/transformers/models/flava/processing_flava.py
@@ -16,20 +16,11 @@
"""
from ...processing_utils import ProcessorMixin
+from ...utils import auto_docstring
+@auto_docstring
class FlavaProcessor(ProcessorMixin):
- r"""
- Constructs a FLAVA processor which wraps a FLAVA image processor and a FLAVA tokenizer into a single processor.
-
- [`FlavaProcessor`] offers all the functionalities of [`FlavaImageProcessor`] and [`BertTokenizerFast`]. See the
- [`~FlavaProcessor.__call__`] and [`~FlavaProcessor.decode`] for more information.
-
- Args:
- image_processor ([`FlavaImageProcessor`], *optional*): The image processor is a required input.
- tokenizer ([`BertTokenizerFast`], *optional*): The tokenizer is a required input.
- """
-
def __init__(self, image_processor=None, tokenizer=None, **kwargs):
super().__init__(image_processor, tokenizer)
diff --git a/src/transformers/models/florence2/modular_florence2.py b/src/transformers/models/florence2/modular_florence2.py
index 2db9e0ca998c..dc6fa1755712 100644
--- a/src/transformers/models/florence2/modular_florence2.py
+++ b/src/transformers/models/florence2/modular_florence2.py
@@ -236,26 +236,8 @@ class Florence2ProcessorKwargs(LlavaProcessorKwargs):
pass
+@auto_docstring
class Florence2Processor(ProcessorMixin):
- r"""
- Constructs a Florence2 processor which wraps a Florence2 image processor and a Florence2 tokenizer into a single processor.
-
- [`Florence2Processor`] offers all the functionalities of [`AutoImageProcessor`] and [`BartTokenizerFast`]. See the
- [`~Florence2Processor.__call__`] and [`~Florence2Processor.decode`] for more information.
-
- Args:
- image_processor (`AutoImageProcessor`, *optional*):
- The image processor is a required input.
- tokenizer (`Union[BartTokenizer, BartTokenizerFast]`, *optional*):
- The tokenizer is a required input.
- num_additional_image_tokens (`int`, *optional*, defaults to 0):
- Number of additional tokens added to the image embeddings, such as CLS (+1). If the backbone has no CLS or other
- extra tokens appended, no need to set this arg.
- post_processor_config (`dict`, *optional*, defaults to 0):
- Task-specific parsing rules for [`Florence2PostProcessor`], e.g. regex patterns,
- thresholds, or banned tokens.
- """
-
def __init__(
self,
image_processor=None,
@@ -264,6 +246,14 @@ def __init__(
post_processor_config: dict | None = None,
**kwargs,
):
+ r"""
+ num_additional_image_tokens (`int`, *optional*, defaults to 0):
+ Number of additional tokens added to the image embeddings, such as CLS (+1). If the backbone has no CLS or other
+ extra tokens appended, no need to set this arg.
+ post_processor_config (`dict`, *optional*, defaults to 0):
+ Task-specific parsing rules for [`Florence2PostProcessor`], e.g. regex patterns,
+ thresholds, or banned tokens.
+ """
self.tasks_answer_post_processing_type = {
"": "pure_text",
"": "ocr",
@@ -337,32 +327,14 @@ def _construct_prompts(self, text: str | list[str]) -> list[str]:
prompts.append(prompt)
return prompts
+ @auto_docstring
def __call__(
self,
images: ImageInput | None = None,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
**kwargs: Unpack[Florence2ProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to BartTokenizerFast's [`~BartTokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- CLIPImageProcessor's [`~CLIPImageProcessor.__call__`] if `images` is not `None`. Please refer to the docstring
- of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/florence2/processing_florence2.py b/src/transformers/models/florence2/processing_florence2.py
index 84f667ebaaf8..a90bc2a9561f 100644
--- a/src/transformers/models/florence2/processing_florence2.py
+++ b/src/transformers/models/florence2/processing_florence2.py
@@ -26,7 +26,7 @@
from ...image_utils import ImageInput
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import is_torch_available, logging
+from ...utils import auto_docstring, is_torch_available, logging
if is_torch_available():
@@ -41,26 +41,8 @@ class Florence2ProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Florence2Processor(ProcessorMixin):
- r"""
- Constructs a Florence2 processor which wraps a Florence2 image processor and a Florence2 tokenizer into a single processor.
-
- [`Florence2Processor`] offers all the functionalities of [`AutoImageProcessor`] and [`BartTokenizerFast`]. See the
- [`~Florence2Processor.__call__`] and [`~Florence2Processor.decode`] for more information.
-
- Args:
- image_processor (`AutoImageProcessor`, *optional*):
- The image processor is a required input.
- tokenizer (`Union[BartTokenizer, BartTokenizerFast]`, *optional*):
- The tokenizer is a required input.
- num_additional_image_tokens (`int`, *optional*, defaults to 0):
- Number of additional tokens added to the image embeddings, such as CLS (+1). If the backbone has no CLS or other
- extra tokens appended, no need to set this arg.
- post_processor_config (`dict`, *optional*, defaults to 0):
- Task-specific parsing rules for [`Florence2PostProcessor`], e.g. regex patterns,
- thresholds, or banned tokens.
- """
-
def __init__(
self,
image_processor=None,
@@ -69,6 +51,14 @@ def __init__(
post_processor_config: dict | None = None,
**kwargs,
):
+ r"""
+ num_additional_image_tokens (`int`, *optional*, defaults to 0):
+ Number of additional tokens added to the image embeddings, such as CLS (+1). If the backbone has no CLS or other
+ extra tokens appended, no need to set this arg.
+ post_processor_config (`dict`, *optional*, defaults to 0):
+ Task-specific parsing rules for [`Florence2PostProcessor`], e.g. regex patterns,
+ thresholds, or banned tokens.
+ """
self.tasks_answer_post_processing_type = {
"": "pure_text",
"": "ocr",
@@ -142,32 +132,14 @@ def _construct_prompts(self, text: str | list[str]) -> list[str]:
prompts.append(prompt)
return prompts
+ @auto_docstring
def __call__(
self,
images: ImageInput | None = None,
text: TextInput | PreTokenizedInput | list[TextInput] | list[PreTokenizedInput] = None,
**kwargs: Unpack[Florence2ProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to BartTokenizerFast's [`~BartTokenizerFast.__call__`] if `text` is not `None` to encode
- the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- CLIPImageProcessor's [`~CLIPImageProcessor.__call__`] if `images` is not `None`. Please refer to the docstring
- of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/fuyu/processing_fuyu.py b/src/transformers/models/fuyu/processing_fuyu.py
index 0fa107ac6933..7882ed9c39dc 100644
--- a/src/transformers/models/fuyu/processing_fuyu.py
+++ b/src/transformers/models/fuyu/processing_fuyu.py
@@ -28,7 +28,7 @@
Unpack,
)
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import is_torch_available, logging, requires_backends
+from ...utils import auto_docstring, is_torch_available, logging, requires_backends
from ...utils.import_utils import requires
@@ -332,20 +332,8 @@ def scale_bbox_to_transformed_image(
@requires(backends=("vision",))
+@auto_docstring
class FuyuProcessor(ProcessorMixin):
- r"""
- Constructs a Fuyu processor which wraps a Fuyu image processor and a Llama tokenizer into a single processor.
-
- [`FuyuProcessor`] offers all the functionalities of [`FuyuImageProcessor`] and [`TokenizersBackend`]. See the
- [`~FuyuProcessor.__call__`] and [`~FuyuProcessor.decode`] for more information.
-
- Args:
- image_processor ([`FuyuImageProcessor`]):
- The image processor is a required input.
- tokenizer ([`TokenizersBackend`]):
- The tokenizer is a required input.
- """
-
@classmethod
def _load_tokenizer_from_pretrained(
cls, sub_processor_type, pretrained_model_name_or_path, subfolder="", **kwargs
@@ -493,28 +481,14 @@ def get_sample_encoding(
}
return batch_encoding
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[str, list[str], TextInput, PreTokenizedInput]] = None,
**kwargs: Unpack[FuyuProcessorKwargs],
) -> "FuyuBatchFeature":
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to TokenizersBackend's [`~TokenizersBackend.__call__`] if `text` is not `None` to
- encode the text. To prepare the image(s), this method forwards the `images` and `kwargs` arguments to
- FuyuImageProcessor's [`~FuyuImageProcessor.__call__`] if `images` is not `None`. Please refer to the docstring
- of the above two methods for more information.
-
- Args:
- images (`PIL.Image.Image`, `list[PIL.Image.Image]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `list[str]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
-
+ r"""
Returns:
[`FuyuBatchEncoding`]: A [`FuyuBatchEncoding`] with the following fields:
diff --git a/src/transformers/models/gemma3/processing_gemma3.py b/src/transformers/models/gemma3/processing_gemma3.py
index de873300409b..a6538f0e9aeb 100644
--- a/src/transformers/models/gemma3/processing_gemma3.py
+++ b/src/transformers/models/gemma3/processing_gemma3.py
@@ -21,7 +21,7 @@
from ...image_utils import ImageInput, make_nested_list_of_images
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import to_py_obj
+from ...utils import auto_docstring, to_py_obj
class Gemma3ProcessorKwargs(ProcessingKwargs, total=False):
@@ -40,6 +40,7 @@ class Gemma3ProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Gemma3Processor(ProcessorMixin):
def __init__(
self,
@@ -63,6 +64,7 @@ def __init__(
**kwargs,
)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
diff --git a/src/transformers/models/gemma3n/processing_gemma3n.py b/src/transformers/models/gemma3n/processing_gemma3n.py
index 501b318daf7b..8ed7e9682dbc 100644
--- a/src/transformers/models/gemma3n/processing_gemma3n.py
+++ b/src/transformers/models/gemma3n/processing_gemma3n.py
@@ -20,6 +20,7 @@
from ...image_utils import ImageInput, make_nested_list_of_images
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
+from ...utils import auto_docstring
class Gemma3nProcessorKwargs(ProcessingKwargs, total=False):
@@ -28,28 +29,8 @@ class Gemma3nProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Gemma3nProcessor(ProcessorMixin):
- """
- A processor for Gemma 3n, wrapping the full capabilities of a feature extractor, image processor, and tokenizer
- into a single processor.
-
- Args:
- feature_extractor (`Gemma3nAudioFeatureExtractor`):
- Feature extractor that converts raw audio waveforms into MEL spectrograms for the audio encoder. This
- should return a `BatchFeature` with `input_features` and `input_features_mask` features.
- image_processor (`SiglipImageProcessorFast`):
- Image processor that prepares batches of images for the vision encoder. This should return a `BatchFeature`
- with a `pixel_values` feature.
- tokenizer (`GemmaTokenizerFast`):
- The text tokenizer for the model.
- chat_template (`string`, *optional*):
- A Jinja template for generating text prompts from a set of messages.
- audio_seq_length (int, *optional*, defaults to 188):
- The number of audio soft tokens that will be added to the text prompt
- image_seq_length (int, *optional*, defaults to 256):
- The number of image soft tokens that should be added to
- """
-
def __init__(
self,
feature_extractor,
@@ -60,6 +41,12 @@ def __init__(
image_seq_length: int = 256,
**kwargs,
):
+ r"""
+ audio_seq_length (int, *optional*, defaults to 188):
+ The number of audio soft tokens that will be added to the text prompt
+ image_seq_length (int, *optional*, defaults to 256):
+ The number of image soft tokens that should be added to
+ """
self.audio_seq_length = audio_seq_length
self.audio_token_id = tokenizer.audio_token_id
self.boa_token = tokenizer.boa_token
@@ -82,6 +69,7 @@ def __init__(
**kwargs,
)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
diff --git a/src/transformers/models/git/processing_git.py b/src/transformers/models/git/processing_git.py
index c614079a29e2..2a4399b3c51c 100644
--- a/src/transformers/models/git/processing_git.py
+++ b/src/transformers/models/git/processing_git.py
@@ -16,22 +16,11 @@
"""
from ...processing_utils import ProcessorMixin
+from ...utils import auto_docstring
+@auto_docstring
class GitProcessor(ProcessorMixin):
- r"""
- Constructs a GIT processor which wraps a CLIP image processor and a BERT tokenizer into a single processor.
-
- [`GitProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`BertTokenizerFast`]. See the
- [`~GitProcessor.__call__`] and [`~GitProcessor.decode`] for more information.
-
- Args:
- image_processor ([`AutoImageProcessor`]):
- The image processor is a required input.
- tokenizer ([`AutoTokenizer`]):
- The tokenizer is a required input.
- """
-
def __init__(self, image_processor, tokenizer):
super().__init__(image_processor, tokenizer)
diff --git a/src/transformers/models/glm46v/processing_glm46v.py b/src/transformers/models/glm46v/processing_glm46v.py
index 2daa9c69cdb1..99bc1cbd8dcd 100644
--- a/src/transformers/models/glm46v/processing_glm46v.py
+++ b/src/transformers/models/glm46v/processing_glm46v.py
@@ -25,7 +25,7 @@
from ...image_utils import ImageInput
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import logging
+from ...utils import auto_docstring, logging
from ...video_utils import VideoInput
@@ -43,21 +43,8 @@ class Glm46VProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Glm46VProcessor(ProcessorMixin):
- r"""
- Constructs a GLM-4V processor which wraps a GLM-4V image processor and a GLM-4 tokenizer into a single processor.
- [`~Glm46VProcessor.__call__`] and [`~Glm46VProcessor.decode`] for more information.
- Args:
- image_processor ([`Glm46VProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`PreTrainedTokenizerFast`], *optional*):
- The tokenizer is a required input.
- video_processor ([`Glm46VVideoProcessor`], *optional*):
- The video processor is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
def __init__(self, image_processor=None, tokenizer=None, video_processor=None, chat_template=None, **kwargs):
self.image_token = "<|image|>" if not hasattr(tokenizer, "image_token") else tokenizer.image_token
self.video_token = "<|video|>" if not hasattr(tokenizer, "video_token") else tokenizer.video_token
@@ -73,6 +60,7 @@ def __init__(self, image_processor=None, tokenizer=None, video_processor=None, c
)
super().__init__(image_processor, tokenizer, video_processor, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
images: ImageInput | None = None,
@@ -80,27 +68,7 @@ def __call__(
videos: VideoInput | None = None,
**kwargs: Unpack[Glm46VProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to PreTrainedTokenizerFast's [`~PreTrainedTokenizerFast.__call__`] if `text` is not `None` to encode
- the text.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `List[str]`, `List[List[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- videos (`np.ndarray`, `torch.Tensor`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of videos to be prepared. Each video can be a 4D NumPy array or PyTorch
- tensor, or a nested list of 3D frames. Both channels-first and channels-last formats are supported.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/glm4v/modular_glm4v.py b/src/transformers/models/glm4v/modular_glm4v.py
index 0fc8cda3f136..61edcdc7a390 100644
--- a/src/transformers/models/glm4v/modular_glm4v.py
+++ b/src/transformers/models/glm4v/modular_glm4v.py
@@ -1517,20 +1517,6 @@ class Glm4vProcessorKwargs(Qwen2VLProcessorKwargs):
class Glm4vProcessor(Qwen2VLProcessor):
- r"""
- Constructs a GLM-4V processor which wraps a GLM-4V image processor and a GLM-4 tokenizer into a single processor.
- [`~Glm4vProcessor.__call__`] and [`~Glm4vProcessor.decode`] for more information.
- Args:
- image_processor ([`Glm4vProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`PreTrainedTokenizerFast`], *optional*):
- The tokenizer is a required input.
- video_processor ([`Glm4vVideoProcessor`], *optional*):
- The video processor is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
def __init__(self, image_processor=None, tokenizer=None, video_processor=None, chat_template=None, **kwargs):
super().__init__(image_processor, tokenizer, video_processor, chat_template=chat_template)
self.image_token = "<|image|>" if not hasattr(tokenizer, "image_token") else tokenizer.image_token
@@ -1543,27 +1529,7 @@ def __call__(
videos: VideoInput | None = None,
**kwargs: Unpack[Glm4vProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to PreTrainedTokenizerFast's [`~PreTrainedTokenizerFast.__call__`] if `text` is not `None` to encode
- the text.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `List[str]`, `List[List[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- videos (`np.ndarray`, `torch.Tensor`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of videos to be prepared. Each video can be a 4D NumPy array or PyTorch
- tensor, or a nested list of 3D frames. Both channels-first and channels-last formats are supported.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/glm4v/processing_glm4v.py b/src/transformers/models/glm4v/processing_glm4v.py
index 69a1533c3eea..c8fe12e39006 100644
--- a/src/transformers/models/glm4v/processing_glm4v.py
+++ b/src/transformers/models/glm4v/processing_glm4v.py
@@ -24,7 +24,7 @@
from ...image_utils import ImageInput
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import logging
+from ...utils import auto_docstring, logging
from ...video_utils import VideoInput
@@ -42,21 +42,8 @@ class Glm4vProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Glm4vProcessor(ProcessorMixin):
- r"""
- Constructs a GLM-4V processor which wraps a GLM-4V image processor and a GLM-4 tokenizer into a single processor.
- [`~Glm4vProcessor.__call__`] and [`~Glm4vProcessor.decode`] for more information.
- Args:
- image_processor ([`Glm4vProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`PreTrainedTokenizerFast`], *optional*):
- The tokenizer is a required input.
- video_processor ([`Glm4vVideoProcessor`], *optional*):
- The video processor is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
def __init__(self, image_processor=None, tokenizer=None, video_processor=None, chat_template=None, **kwargs):
self.image_token = "<|image|>" if not hasattr(tokenizer, "image_token") else tokenizer.image_token
self.video_token = "<|video|>" if not hasattr(tokenizer, "video_token") else tokenizer.video_token
@@ -72,6 +59,7 @@ def __init__(self, image_processor=None, tokenizer=None, video_processor=None, c
)
super().__init__(image_processor, tokenizer, video_processor, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
images: ImageInput | None = None,
@@ -79,27 +67,7 @@ def __call__(
videos: VideoInput | None = None,
**kwargs: Unpack[Glm4vProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to PreTrainedTokenizerFast's [`~PreTrainedTokenizerFast.__call__`] if `text` is not `None` to encode
- the text.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `List[str]`, `List[List[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- videos (`np.ndarray`, `torch.Tensor`, `List[np.ndarray]`, `List[torch.Tensor]`):
- The image or batch of videos to be prepared. Each video can be a 4D NumPy array or PyTorch
- tensor, or a nested list of 3D frames. Both channels-first and channels-last formats are supported.
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/got_ocr2/processing_got_ocr2.py b/src/transformers/models/got_ocr2/processing_got_ocr2.py
index 31bd06eb6fa2..db69e7673f09 100644
--- a/src/transformers/models/got_ocr2/processing_got_ocr2.py
+++ b/src/transformers/models/got_ocr2/processing_got_ocr2.py
@@ -21,7 +21,7 @@
from ...image_utils import ImageInput
from ...processing_utils import ImagesKwargs, ProcessingKwargs, ProcessorMixin, TextKwargs, Unpack
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import is_vision_available, logging
+from ...utils import auto_docstring, is_vision_available, logging
if is_vision_available():
@@ -31,10 +31,42 @@
class GotOcr2TextKwargs(TextKwargs, total=False):
+ """
+ format (`bool`, *optional*, defaults to `False`):
+ Whether to request formatted output from the OCR model. When enabled, the model is instructed to return
+ structured and formatted text output rather than raw OCR results.
+ """
+
format: Optional[bool]
class GotOcr2ImagesKwargs(ImagesKwargs, total=False):
+ """
+ crop_to_patches (`bool`, *optional*, defaults to `False`):
+ Whether to crop images into patches before processing. When enabled, large images are divided into
+ smaller patches for more efficient OCR processing.
+ min_patches (`int`, *optional*, defaults to `1`):
+ Minimum number of patches to generate when cropping images. This ensures that even small images are
+ processed with at least this many patches.
+ max_patches (`int`, *optional*, defaults to `12`):
+ Maximum number of patches to generate when cropping images. Large images will be divided into at most
+ this many patches to control computational complexity.
+ box (`list`, `tuple[float, float]`, or `tuple[float, float, float, float]`, *optional*):
+ Bounding box coordinates for OCR region of interest. Can be specified as a single box `[x1, y1, x2, y2]`
+ or a list of boxes. Coordinates are normalized to the range [0, 1000] based on the image dimensions.
+ If not provided, OCR is performed on the entire image.
+ color (`str`, *optional*):
+ Color filter specification for OCR. When provided, the OCR query is prefixed with the color information
+ to focus on text of a specific color (e.g., "red", "blue").
+ num_image_tokens (`int`, *optional*, defaults to `256`):
+ Number of image tokens (patches) to use per image. This controls the resolution of the image representation
+ passed to the model. Higher values provide more detail but increase computational cost.
+ multi_page (`bool`, *optional*, defaults to `False`):
+ Whether the input consists of multi-page documents. When enabled, images can be provided as nested lists
+ where each inner list represents a page, and OCR is performed across all pages with appropriate handling
+ of page boundaries.
+ """
+
crop_to_patches: bool
min_patches: int
max_patches: int
@@ -78,20 +110,8 @@ def preprocess_box_annotation(box: Union[list, tuple], image_size: tuple[int, in
return list(box)
+@auto_docstring
class GotOcr2Processor(ProcessorMixin):
- r"""
- Constructs a GotOcr2 processor which wraps a [`GotOcr2ImageProcessor`] and
- [`PretrainedTokenizerFast`] tokenizer into a single processor that inherits both the image processor and
- tokenizer functionalities. See the [`~GotOcr2Processor.__call__`] and [`~GotOcr2Processor.decode`] for more information.
- Args:
- image_processor ([`GotOcr2ImageProcessor`], *optional*):
- The image processor is a required input.
- tokenizer ([`PreTrainedTokenizer`, `PreTrainedTokenizerFast`], *optional*):
- The tokenizer is a required input.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
def __init__(self, image_processor=None, tokenizer=None, chat_template=None, **kwargs):
super().__init__(image_processor, tokenizer, chat_template=chat_template)
@@ -126,52 +146,14 @@ def _make_list_of_inputs(self, images, text, box, color, multi_page):
return images, text, box, color
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Optional[Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]]] = None,
**kwargs: Unpack[GotOcr2ProcessorKwargs],
) -> BatchFeature:
- """
- Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
- and `kwargs` arguments to PreTrainedTokenizerFast's [`~PreTrainedTokenizerFast.__call__`] to encode the text if `text`
- is not `None`, otherwise encode default OCR queries which depends on the `format`, `box`, `color`, `multi_page` and
- `crop_to_patches` arguments. To prepare the vision inputs, this method forwards the `images` and `kwargs` arguments to
- GotOcr2ImageProcessor's [`~GotOcr2ImageProcessor.__call__`] if `images` is not `None`.
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`str`, `list[str]`, `list[list[str]]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- format (`bool`, *optional*):
- If set, will add the format token to the query, and the model will return the OCR result with formatting.
- box (`list[float]`, `list[tuple[float, float]]`, `list[tuple[float, float, float, float]]`, *optional*):
- The box annotation to be added to the query. If a list of floats or a tuple of floats is provided, it
- will be interpreted as [x1, y1, x2, y2]. If a list of tuples is provided, each tuple should be in the
- form (x1, y1, x2, y2).
- color (`str`, *optional*):
- The color annotation to be added to the query. The model will return the OCR result within the box with
- the specified color.
- multi_page (`bool`, *optional*):
- If set, will enable multi-page inference. The model will return the OCR result across multiple pages.
- crop_to_patches (`bool`, *optional*):
- If set, will crop the image to patches. The model will return the OCR result upon the patch reference.
- min_patches (`int`, *optional*):
- The minimum number of patches to be cropped from the image. Only used when `crop_to_patches` is set to
- `True`.
- max_patches (`int`, *optional*):
- The maximum number of patches to be cropped from the image. Only used when `crop_to_patches` is set to
- `True`.
-
- return_tensors (`str` or [`~utils.TensorType`], *optional*):
- If set, will return tensors of a particular framework. Acceptable values are:
- - `'pt'`: Return PyTorch `torch.Tensor` objects.
- - `'np'`: Return NumPy `np.ndarray` objects.
-
+ r"""
Returns:
[`BatchFeature`]: A [`BatchFeature`] with the following fields:
diff --git a/src/transformers/models/granite_speech/processing_granite_speech.py b/src/transformers/models/granite_speech/processing_granite_speech.py
index 9484f9b74841..1ffe267e3cf7 100644
--- a/src/transformers/models/granite_speech/processing_granite_speech.py
+++ b/src/transformers/models/granite_speech/processing_granite_speech.py
@@ -18,7 +18,7 @@
from ...feature_extraction_utils import BatchFeature
from ...processing_utils import ProcessorMixin
from ...tokenization_python import PreTokenizedInput, TextInput
-from ...utils import is_torch_available, logging
+from ...utils import auto_docstring, is_torch_available, logging
from ...utils.import_utils import requires_backends
@@ -28,6 +28,7 @@
logger = logging.get_logger(__name__)
+@auto_docstring
class GraniteSpeechProcessor(ProcessorMixin):
def __init__(
self,
@@ -36,9 +37,16 @@ def __init__(
audio_token="<|audio|>",
chat_template=None,
):
+ r"""
+ audio_token (`str`, *optional*, defaults to `"<|audio|>"`):
+ The special token used to represent audio in the text sequence. This token serves as a placeholder
+ that will be replaced with multiple audio tokens based on the actual audio length. The number of
+ audio tokens inserted depends on the audio feature dimensions extracted by the audio processor.
+ """
self.audio_token = tokenizer.audio_token if hasattr(tokenizer, "audio_token") else audio_token
super().__init__(audio_processor, tokenizer, chat_template=chat_template)
+ @auto_docstring
def __call__(
self,
text: Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]],
diff --git a/src/transformers/models/granitemoehybrid/modeling_granitemoehybrid.py b/src/transformers/models/granitemoehybrid/modeling_granitemoehybrid.py
index f920f8284853..4f227bd0ea6c 100644
--- a/src/transformers/models/granitemoehybrid/modeling_granitemoehybrid.py
+++ b/src/transformers/models/granitemoehybrid/modeling_granitemoehybrid.py
@@ -1116,17 +1116,16 @@ class GraniteFlashAttentionKwargs(TypedDict, total=False):
Keyword arguments for advanced Flash Attention, causal-conv1d, and mamba_ssm kernel usage.
Use cases include padding-free training and fewer `torch.compile` graph breaks.
- Attributes:
- cu_seq_lens_q (`torch.LongTensor`)
- Gets cumulative sequence length for query state.
- cu_seq_lens_k (`torch.LongTensor`)
- Gets cumulative sequence length for key state.
- max_length_q (`int`):
- Maximum sequence length for query state.
- max_length_k (`int`):
- Maximum sequence length for key state.
- seq_idx (`torch.IntTensor):
- Index of each packed sequence.
+ cu_seq_lens_q (`torch.LongTensor`):
+ Gets cumulative sequence length for query state.
+ cu_seq_lens_k (`torch.LongTensor`):
+ Gets cumulative sequence length for key state.
+ max_length_q (`int`):
+ Maximum sequence length for query state.
+ max_length_k (`int`):
+ Maximum sequence length for key state.
+ seq_idx (`torch.IntTensor):
+ Index of each packed sequence.
"""
cu_seq_lens_q: torch.LongTensor
diff --git a/src/transformers/models/granitemoeshared/modeling_granitemoeshared.py b/src/transformers/models/granitemoeshared/modeling_granitemoeshared.py
index 153661f91dd5..6b985c05a2c1 100644
--- a/src/transformers/models/granitemoeshared/modeling_granitemoeshared.py
+++ b/src/transformers/models/granitemoeshared/modeling_granitemoeshared.py
@@ -46,17 +46,16 @@ class GraniteFlashAttentionKwargs(TypedDict, total=False):
Keyword arguments for advanced Flash Attention, causal-conv1d, and mamba_ssm kernel usage.
Use cases include padding-free training and fewer `torch.compile` graph breaks.
- Attributes:
- cu_seq_lens_q (`torch.LongTensor`)
- Gets cumulative sequence length for query state.
- cu_seq_lens_k (`torch.LongTensor`)
- Gets cumulative sequence length for key state.
- max_length_q (`int`):
- Maximum sequence length for query state.
- max_length_k (`int`):
- Maximum sequence length for key state.
- seq_idx (`torch.IntTensor):
- Index of each packed sequence.
+ cu_seq_lens_q (`torch.LongTensor`):
+ Gets cumulative sequence length for query state.
+ cu_seq_lens_k (`torch.LongTensor`):
+ Gets cumulative sequence length for key state.
+ max_length_q (`int`):
+ Maximum sequence length for query state.
+ max_length_k (`int`):
+ Maximum sequence length for key state.
+ seq_idx (`torch.IntTensor):
+ Index of each packed sequence.
"""
cu_seq_lens_q: torch.LongTensor
diff --git a/src/transformers/models/granitemoeshared/modular_granitemoeshared.py b/src/transformers/models/granitemoeshared/modular_granitemoeshared.py
index e3b35fbe7c64..efb03ad06a87 100644
--- a/src/transformers/models/granitemoeshared/modular_granitemoeshared.py
+++ b/src/transformers/models/granitemoeshared/modular_granitemoeshared.py
@@ -38,17 +38,16 @@ class GraniteFlashAttentionKwargs(TypedDict, total=False):
Keyword arguments for advanced Flash Attention, causal-conv1d, and mamba_ssm kernel usage.
Use cases include padding-free training and fewer `torch.compile` graph breaks.
- Attributes:
- cu_seq_lens_q (`torch.LongTensor`)
- Gets cumulative sequence length for query state.
- cu_seq_lens_k (`torch.LongTensor`)
- Gets cumulative sequence length for key state.
- max_length_q (`int`):
- Maximum sequence length for query state.
- max_length_k (`int`):
- Maximum sequence length for key state.
- seq_idx (`torch.IntTensor):
- Index of each packed sequence.
+ cu_seq_lens_q (`torch.LongTensor`):
+ Gets cumulative sequence length for query state.
+ cu_seq_lens_k (`torch.LongTensor`):
+ Gets cumulative sequence length for key state.
+ max_length_q (`int`):
+ Maximum sequence length for query state.
+ max_length_k (`int`):
+ Maximum sequence length for key state.
+ seq_idx (`torch.IntTensor):
+ Index of each packed sequence.
"""
cu_seq_lens_q: torch.LongTensor
diff --git a/src/transformers/models/grounding_dino/processing_grounding_dino.py b/src/transformers/models/grounding_dino/processing_grounding_dino.py
index 7164676e688e..22c51b3c90a6 100644
--- a/src/transformers/models/grounding_dino/processing_grounding_dino.py
+++ b/src/transformers/models/grounding_dino/processing_grounding_dino.py
@@ -22,7 +22,7 @@
from ...image_utils import ImageInput
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import BatchEncoding, PreTokenizedInput, TextInput
-from ...utils import TensorType, is_torch_available
+from ...utils import TensorType, auto_docstring, is_torch_available
if is_torch_available():
@@ -113,47 +113,20 @@ class GroundingDinoProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class GroundingDinoProcessor(ProcessorMixin):
- r"""
- Constructs a Grounding DINO processor which wraps a Deformable DETR image processor and a BERT tokenizer into a
- single processor.
-
- [`GroundingDinoProcessor`] offers all the functionalities of [`GroundingDinoImageProcessor`] and
- [`AutoTokenizer`]. See the docstring of [`~GroundingDinoProcessor.__call__`] and [`~GroundingDinoProcessor.decode`]
- for more information.
-
- Args:
- image_processor (`GroundingDinoImageProcessor`):
- An instance of [`GroundingDinoImageProcessor`]. The image processor is a required input.
- tokenizer (`AutoTokenizer`):
- An instance of ['PreTrainedTokenizer`]. The tokenizer is a required input.
- """
-
valid_processor_kwargs = GroundingDinoProcessorKwargs
def __init__(self, image_processor, tokenizer):
super().__init__(image_processor, tokenizer)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]] = None,
**kwargs: Unpack[GroundingDinoProcessorKwargs],
) -> BatchEncoding:
- """
- This method uses [`GroundingDinoImageProcessor.__call__`] method to prepare image(s) for the model, and
- [`BertTokenizerFast.__call__`] to prepare text for the model.
-
- Args:
- images (`ImageInput`, `list[ImageInput]`, *optional*):
- The image or batch of images to be processed. The image might be either PIL image, numpy array or a torch tensor.
- text (`TextInput`, `PreTokenizedInput`, `list[TextInput]`, `list[PreTokenizedInput]`, *optional*):
- Candidate labels to be detected on the image. The text might be one of the following:
- - A list of candidate labels (strings) to be detected on the image (e.g. ["a cat", "a dog"]).
- - A batch of candidate labels to be detected on the batch of images (e.g. [["a cat", "a dog"], ["a car", "a person"]]).
- - A merged candidate labels string to be detected on the image, separated by "." (e.g. "a cat. a dog.").
- - A batch of merged candidate labels text to be detected on the batch of images (e.g. ["a cat. a dog.", "a car. a person."]).
- """
if text is not None:
text = self._preprocess_input_text(text)
return super().__call__(images=images, text=text, **kwargs)
diff --git a/src/transformers/models/idefics/processing_idefics.py b/src/transformers/models/idefics/processing_idefics.py
index e2f3f62309e7..b82703635a5b 100644
--- a/src/transformers/models/idefics/processing_idefics.py
+++ b/src/transformers/models/idefics/processing_idefics.py
@@ -27,7 +27,7 @@
Unpack,
)
from ...tokenization_utils_base import PreTokenizedInput, TextInput
-from ...utils import is_torch_available
+from ...utils import auto_docstring, is_torch_available
if is_torch_available():
@@ -38,6 +38,16 @@
class IdeficsTextKwargs(TextKwargs, total=False):
+ """
+ add_eos_token (`bool`, *optional*, defaults to `False`):
+ Whether to add an end-of-sequence token at the end of the text input. When enabled, an EOS token is
+ appended to mark the end of the text sequence, which is useful for generation tasks.
+ add_end_of_utterance_token (`bool`, *optional*):
+ Whether to add an end-of-utterance token to mark the end of a user's message in conversational contexts.
+ This token helps the model distinguish between different utterances in a multi-turn conversation and is
+ particularly important for chat-based models.
+ """
+
add_eos_token: Optional[bool]
add_end_of_utterance_token: Optional[bool]
@@ -133,25 +143,15 @@ def is_url(string):
return all([result.scheme, result.netloc])
+@auto_docstring
class IdeficsProcessor(ProcessorMixin):
- r"""
- Constructs a IDEFICS processor which wraps a LLama tokenizer and IDEFICS image processor into a single processor.
-
- [`IdeficsProcessor`] offers all the functionalities of [`IdeficsImageProcessor`] and [`LlamaTokenizerFast`]. See
- the docstring of [`~IdeficsProcessor.__call__`] and [`~IdeficsProcessor.decode`] for more information.
-
- Args:
- image_processor (`IdeficsImageProcessor`):
- An instance of [`IdeficsImageProcessor`]. The image processor is a required input.
- tokenizer (`LlamaTokenizerFast`):
- An instance of [`LlamaTokenizerFast`]. The tokenizer is a required input.
- image_size (`int`, *optional*, defaults to 224):
- Image size (assuming a square image)
- add_end_of_utterance_token (`str`, *optional*):
- The string representation of token representing end of utterance
- """
-
def __init__(self, image_processor, tokenizer=None, image_size=224, add_end_of_utterance_token=None, **kwargs):
+ r"""
+ image_size (int, *optional*, defaults to 224):
+ The size of the image to be processed.
+ add_end_of_utterance_token (bool, *optional*, defaults to None):
+ Whether to add the end of utterance token to the text.
+ """
super().__init__(image_processor, tokenizer)
self.image_token_id = (
tokenizer.image_token_id
@@ -169,6 +169,7 @@ def __init__(self, image_processor, tokenizer=None, image_size=224, add_end_of_u
"" in self.tokenizer.special_tokens_map.get("additional_special_tokens", [])
)
+ @auto_docstring
def __call__(
self,
images: Union[ImageInput, list[ImageInput], str, list[str], list[list[str]]] = None,
@@ -182,29 +183,16 @@ def __call__(
] = None,
**kwargs: Unpack[IdeficsProcessorKwargs],
) -> BatchFeature:
- """This method takes batched or non-batched prompts made of text and images and converts them into prompts that
- the model was trained on and prepares the image pixel values for the model to process.
-
- Args:
- images (`Union[ImageInput, list[ImageInput], str, list[str], list[list[str]]]`):
- either a single image or a batched list of images - can be passed in when text contains only text prompts,
- in order to use the image-text-to-text behavior.
- text (`Union[list[TextInput], [list[list[TextInput]]]]`):
- either a single prompt or a batched list of prompts - see the detailed description immediately after
- the end of the arguments doc section.
- return_tensors (`str` or `TensorType`, *optional*, defaults to `TensorType.PYTORCH`):
- The type of tensors to return. Can be one of:
- - `TensorType.PYTORCH` or `'pt'`: Return a batch of type `torch.Tensor`.
-
+ r"""
Returns:
a dict with entries: `input_ids`, `attention_mask`, `pixel_values`, `image_attention_mask` which can be
directly passed to `model.generate`
- Detailed explanation:
+ Detailed explanation:
- Each entry in `text` is either a text to be passed as is or an image that will be processed.
+ Each entry in `text` is either a text to be passed as is or an image that will be processed.
- An image can be either an image object (`PIL.Image`) or a url from which the image can be retrieved.
+ An image can be either an image object (`PIL.Image`) or a url from which the image can be retrieved.
When the processor encounters an image it'll inject ``
entry into the prompt.
diff --git a/src/transformers/models/idefics2/processing_idefics2.py b/src/transformers/models/idefics2/processing_idefics2.py
index 5463a45b2c74..340c9397aa6f 100644
--- a/src/transformers/models/idefics2/processing_idefics2.py
+++ b/src/transformers/models/idefics2/processing_idefics2.py
@@ -27,7 +27,7 @@
Unpack,
)
from ...tokenization_utils_base import AddedToken, TextInput
-from ...utils import logging
+from ...utils import auto_docstring, logging
if TYPE_CHECKING:
@@ -55,29 +55,17 @@ class Idefics2ProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Idefics2Processor(ProcessorMixin):
- r"""
- Constructs a IDEFICS2 processor which wraps a LLama tokenizer and IDEFICS2 image processor into a single processor.
-
- [`IdeficsProcessor`] offers all the functionalities of [`Idefics2ImageProcessor`] and [`LlamaTokenizerFast`]. See
- the docstring of [`~IdeficsProcessor.__call__`] and [`~IdeficsProcessor.decode`] for more information.
-
- Args:
- image_processor (`Idefics2ImageProcessor`):
- An instance of [`Idefics2ImageProcessor`]. The image processor is a required input.
- tokenizer (`PreTrainedTokenizerBase`, *optional*):
- An instance of [`PreTrainedTokenizerBase`]. This should correspond with the model's text model. The tokenizer is a required input.
+ def __init__(
+ self, image_processor, tokenizer=None, image_seq_len: int = 64, chat_template: Optional[str] = None, **kwargs
+ ):
+ r"""
image_seq_len (`int`, *optional*, defaults to 64):
The length of the image sequence i.e. the number of tokens per image in the input.
This parameter is used to build the string from the input prompt and image tokens and should match the
config.perceiver_config.resampler_n_latents value for the model used.
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
- def __init__(
- self, image_processor, tokenizer=None, image_seq_len: int = 64, chat_template: Optional[str] = None, **kwargs
- ):
+ """
if not hasattr(tokenizer, "image_token"):
self.fake_image_token = AddedToken("", normalized=False, special=True).content
self.image_token = AddedToken("", normalized=False, special=True).content
@@ -107,58 +95,13 @@ def _extract_images_from_prompts(self, prompts):
prompt_images.append(images)
return prompt_images
+ @auto_docstring
def __call__(
self,
images: Union[ImageInput, list[ImageInput], list[list[ImageInput]]] = None,
text: Union[TextInput, "PreTokenizedInput", list[TextInput], list["PreTokenizedInput"]] = None,
**kwargs: Unpack[Idefics2ProcessorKwargs],
) -> BatchFeature:
- """
- Processes the input prompts and returns a BatchEncoding.
-
- Example:
-
- ```python
- >>> import requests
- >>> from transformers import Idefics2Processor
- >>> from transformers.image_utils import load_image
-
- >>> processor = Idefics2Processor.from_pretrained("HuggingFaceM4/idefics2-8b", image_seq_len=2)
- >>> processor.image_processor.do_image_splitting = False # Force as False to simplify the example
-
- >>> url1 = "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
- >>> url2 = "https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg"
-
- >>> image1, image2 = load_image(url1), load_image(url2)
- >>> images = [[image1], [image2]]
-
- >>> text = [
- ... "In this image, we see",
- ... "bla bla bla",
- ... ]
- >>> outputs = processor(images=images, text=text, return_tensors="pt", padding=True)
- >>> input_ids = outputs.input_ids
- >>> input_tokens = processor.tokenizer.batch_decode(input_ids)
- >>> print(input_tokens)
- [' In this image, we see', ' bla bla bla']
- ```
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`, *optional*):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. If is of type `list[ImageInput]`, it's assumed that this is for a single prompt i.e. of batch size 1.
- text (`Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]]`, *optional*):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
-
- Wherever an image token, `` is encountered it is expanded to
- `` + `` * `image_seq_len` * `.
- return_tensors (`Union[str, TensorType]`, *optional*):
- If set, will return tensors of a particular framework. See [`PreTrainedTokenizerFast.__call__`] for more
- information.
-
- """
if text is None and images is None:
raise ValueError("You must provide either `text` or `images`.")
diff --git a/src/transformers/models/idefics3/processing_idefics3.py b/src/transformers/models/idefics3/processing_idefics3.py
index e915b4ba109f..9e6d4db96b49 100644
--- a/src/transformers/models/idefics3/processing_idefics3.py
+++ b/src/transformers/models/idefics3/processing_idefics3.py
@@ -25,7 +25,7 @@
from ...image_utils import ImageInput, is_valid_image, load_image
from ...processing_utils import MultiModalData, ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import AddedToken, BatchEncoding, TextInput
-from ...utils import logging
+from ...utils import auto_docstring, logging
if TYPE_CHECKING:
@@ -100,29 +100,17 @@ class Idefics3ProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class Idefics3Processor(ProcessorMixin):
- r"""
- Constructs a Idefics3 processor which wraps a LLama tokenizer and Idefics3 image processor into a single processor.
-
- [`Idefics3Processor`] offers all the functionalities of [`Idefics3ImageProcessor`] and [`Idefics3TokenizerFast`]. See
- the docstring of [`~IdeficsProcessor.__call__`] and [`~IdeficsProcessor.decode`] for more information.
-
- Args:
- image_processor (`Idefics3ImageProcessor`):
- An instance of [`Idefics3ImageProcessor`]. The image processor is a required input.
- tokenizer (`PreTrainedTokenizerBase`, *optional*):
- An instance of [`PreTrainedTokenizerBase`]. This should correspond with the model's text model. The tokenizer is a required input.
+ def __init__(
+ self, image_processor, tokenizer=None, image_seq_len: int = 169, chat_template: Optional[str] = None, **kwargs
+ ):
+ r"""
image_seq_len (`int`, *optional*, defaults to 169):
The length of the image sequence i.e. the number of tokens per image in the input.
This parameter is used to build the string from the input prompt and image tokens and should match the
value the model used. It is computed as: image_seq_len = int(((image_size // patch_size) ** 2) / (scale_factor**2))
- chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
- in a chat into a tokenizable string.
- """
-
- def __init__(
- self, image_processor, tokenizer=None, image_seq_len: int = 169, chat_template: Optional[str] = None, **kwargs
- ):
+ """
self.fake_image_token = AddedToken("", normalized=False, special=True).content
self.image_token = AddedToken("", normalized=False, special=True).content
self.end_of_utterance_token = AddedToken("", normalized=False, special=True).content
@@ -163,6 +151,7 @@ def _extract_images_from_prompts(self, prompts):
prompt_images.append(images)
return prompt_images
+ @auto_docstring
def __call__(
self,
images: Union[ImageInput, list[ImageInput], list[list[ImageInput]]] = None,
@@ -170,52 +159,10 @@ def __call__(
image_seq_len: Optional[int] = None,
**kwargs: Unpack[Idefics3ProcessorKwargs],
) -> BatchEncoding:
- """
- Processes the input prompts and returns a BatchEncoding.
-
- Example:
-
- ```python
- >>> import requests
- >>> from transformers import Idefics3Processor
- >>> from transformers.image_utils import load_image
-
- >>> processor = Idefics3Processor.from_pretrained("HuggingFaceM4/Idefics3-8B-Llama3")
- >>> processor.image_processor.do_image_splitting = False # Force as False to simplify the example
-
- >>> url1 = "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
- >>> url2 = "https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg"
-
- >>> image1, image2 = load_image(url1), load_image(url2)
- >>> images = [[image1], [image2]]
-
- >>> text = [
- ... "In this image, we see",
- ... "bla bla bla",
- ... ]
- >>> outputs = processor(images=images, text=text, return_tensors="pt", padding=True)
- >>> input_ids = outputs.input_ids
- >>> input_tokens = processor.tokenizer.batch_decode(input_ids)
- >>> print(input_tokens)
- ['<|begin_of_text|>(()*169) In this image, we see', '<|reserved_special_token_0|><|reserved_special_token_0|><|reserved_special_token_0|><|begin_of_text|>bla bla bla(()*169)']
- ```
-
- Args:
- images (`PIL.Image.Image`, `np.ndarray`, `torch.Tensor`, `list[PIL.Image.Image]`, `list[np.ndarray]`, `list[torch.Tensor]`, *optional*):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. If is of type `list[ImageInput]`, it's assumed that this is for a single prompt i.e. of batch size 1.
- text (`Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]]`, *optional*):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- Wherever an image token, `` is encountered it is expanded to
- `` + `` + `` * `image_seq_len` * `.
- image_seq_len (`int`, *optional*):
- The length of the image sequence. If not provided, the default value of self.image_seq_len is used.
- image_seq_len should be equal to int(((image_size // patch_size) ** 2) / (scale_factor**2))
- return_tensors (`Union[str, TensorType]`, *optional*):
- If set, will return tensors of a particular framework. See [`PreTrainedTokenizerFast.__call__`] for more
- information.
+ r"""
+ image_seq_len (`int`, *optional*):
+ The length of the image sequence. If not provided, the default value of self.image_seq_len is used.
+ image_seq_len should be equal to int(((image_size // patch_size) ** 2) / (scale_factor**2))
"""
if text is None and images is None:
raise ValueError("You must provide either `text` or `images`.")
diff --git a/src/transformers/models/instructblip/processing_instructblip.py b/src/transformers/models/instructblip/processing_instructblip.py
index 4a914ae4a3a0..16ec43294f02 100644
--- a/src/transformers/models/instructblip/processing_instructblip.py
+++ b/src/transformers/models/instructblip/processing_instructblip.py
@@ -21,7 +21,7 @@
from ...image_utils import ImageInput
from ...processing_utils import ProcessingKwargs, ProcessorMixin, Unpack
from ...tokenization_utils_base import AddedToken, PreTokenizedInput, TextInput
-from ...utils import logging
+from ...utils import auto_docstring, logging
logger = logging.get_logger(__name__)
@@ -43,26 +43,16 @@ class InstructBlipProcessorKwargs(ProcessingKwargs, total=False):
}
+@auto_docstring
class InstructBlipProcessor(ProcessorMixin):
- r"""
- Constructs an InstructBLIP processor which wraps a BLIP image processor and a LLaMa/T5 tokenizer into a single
- processor.
-
- [`InstructBlipProcessor`] offers all the functionalities of [`BlipImageProcessor`] and [`AutoTokenizer`]. See the
- docstring of [`~BlipProcessor.__call__`] and [`~BlipProcessor.decode`] for more information.
-
- Args:
- image_processor (`BlipImageProcessor`):
- An instance of [`BlipImageProcessor`]. The image processor is a required input.
- tokenizer (`AutoTokenizer`):
- An instance of ['PreTrainedTokenizer`]. The tokenizer is a required input.
+ def __init__(self, image_processor, tokenizer, qformer_tokenizer, num_query_tokens=None, **kwargs):
+ r"""
qformer_tokenizer (`AutoTokenizer`):
An instance of ['PreTrainedTokenizer`]. The Q-Former tokenizer is a required input.
- num_query_tokens (`int`, *optional*):"
+ num_query_tokens (`int`, *optional*):
+ "
Number of tokens used by the Qformer as queries, should be same as in model's config.
- """
-
- def __init__(self, image_processor, tokenizer, qformer_tokenizer, num_query_tokens=None, **kwargs):
+ """
if not hasattr(tokenizer, "image_token"):
self.image_token = AddedToken("", normalized=False, special=True)
tokenizer.add_tokens([self.image_token], special_tokens=True)
@@ -72,26 +62,13 @@ def __init__(self, image_processor, tokenizer, qformer_tokenizer, num_query_toke
super().__init__(image_processor, tokenizer, qformer_tokenizer)
+ @auto_docstring
def __call__(
self,
images: Optional[ImageInput] = None,
text: Union[TextInput, PreTokenizedInput, list[TextInput], list[PreTokenizedInput]] = None,
**kwargs: Unpack[InstructBlipProcessorKwargs],
) -> BatchFeature:
- """
- This method uses [`BlipImageProcessor.__call__`] method to prepare image(s) for the model, and
- [`BertTokenizerFast.__call__`] to prepare text for the model.
-
- Please refer to the docstring of the above two methods for more information.
- Args:
- images (`ImageInput`):
- The image or batch of images to be prepared. Each image can be a PIL image, NumPy array or PyTorch
- tensor. Both channels-first and channels-last formats are supported.
- text (`TextInput`, `PreTokenizedInput`, `list[TextInput]`, `list[PreTokenizedInput]`):
- The sequence or batch of sequences to be encoded. Each sequence can be a string or a list of strings
- (pretokenized string). If the sequences are provided as list of strings (pretokenized), you must set
- `is_split_into_words=True` (to lift the ambiguity with a batch of sequences).
- """
if images is None and text is None:
raise ValueError("You have to specify at least images or text.")
diff --git a/src/transformers/models/instructblipvideo/processing_instructblipvideo.py b/src/transformers/models/instructblipvideo/processing_instructblipvideo.py
index 61f509ba00ed..10bfb5ab643c 100644
--- a/src/transformers/models/instructblipvideo/processing_instructblipvideo.py
+++ b/src/transformers/models/instructblipvideo/processing_instructblipvideo.py
@@ -26,33 +26,22 @@
TextInput,
TruncationStrategy,
)
-from ...utils import TensorType, logging
+from ...utils import TensorType, auto_docstring, logging
from ...video_utils import VideoInput
logger = logging.get_logger(__name__)
+@auto_docstring
class InstructBlipVideoProcessor(ProcessorMixin):
- r"""
- Constructs an InstructBLIPVideo processor which wraps a InstructBLIP image processor and a LLaMa/T5 tokenizer into a single
- processor.
-
- [`InstructBlipVideoProcessor`] offers all the functionalities of [`InstructBlipVideoVideoProcessor`] and [`AutoTokenizer`]. See the
- docstring of [`~InstructBlipVideoProcessor.__call__`] and [`~InstructBlipVideoProcessor.decode`] for more information.
-
- Args:
- video_processor (`InstructBlipVideoVideoProcessor`):
- An instance of [`InstructBlipVideoVideoProcessor`]. The video processor is a required input.
- tokenizer (`AutoTokenizer`):
- An instance of ['PreTrainedTokenizer`]. The tokenizer is a required input.
+ def __init__(self, video_processor, tokenizer, qformer_tokenizer, num_query_tokens=None, **kwargs):
+ r"""
qformer_tokenizer (`AutoTokenizer`):
An instance of ['PreTrainedTokenizer`]. The Q-Former tokenizer is a required input.
num_query_tokens (`int`, *optional*):
Number of tokens used by the Qformer as queries, should be same as in model's config.
- """
-
- def __init__(self, video_processor, tokenizer, qformer_tokenizer, num_query_tokens=None, **kwargs):
+ """
if not hasattr(tokenizer, "video_token"):
self.video_token = AddedToken("