Bump Transformers version to 5.10.4 (#41359)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -232,7 +232,7 @@ class FireRedLIDProcessor(ProcessorMixin):
|
||||
"""
|
||||
|
||||
feature_extractor_class = "FireRedLIDFeatureExtractor"
|
||||
tokenizer_class = ("PreTrainedTokenizer", "PreTrainedTokenizerFast")
|
||||
tokenizer_class = ("PythonBackend", "TokenizersBackend")
|
||||
|
||||
def __init__(self, feature_extractor, tokenizer):
|
||||
super().__init__(feature_extractor, tokenizer)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
# Adapted from
|
||||
# https://github.com/zai-org/CogAgent
|
||||
from transformers import PreTrainedTokenizer
|
||||
from transformers import PythonBackend
|
||||
from transformers.image_processing_utils_fast import BaseImageProcessorFast
|
||||
from transformers.image_utils import PILImageResampling
|
||||
from transformers.processing_utils import ProcessorMixin
|
||||
@@ -30,7 +30,7 @@ class GLM4VProcessor(ProcessorMixin):
|
||||
def __init__(
|
||||
self,
|
||||
image_processor: GLM4VImageProcessorFast,
|
||||
tokenizer: PreTrainedTokenizer,
|
||||
tokenizer: PythonBackend,
|
||||
) -> None:
|
||||
self.image_processor = image_processor
|
||||
self.tokenizer = tokenizer
|
||||
|
||||
@@ -12,7 +12,12 @@ import numpy.typing as npt
|
||||
import torch
|
||||
import torchvision.transforms as T
|
||||
from PIL import Image
|
||||
from transformers import BatchFeature, TensorType
|
||||
from transformers import (
|
||||
BaseVideoProcessor,
|
||||
BatchFeature,
|
||||
ImageProcessingMixin,
|
||||
TensorType,
|
||||
)
|
||||
from transformers.processing_utils import ProcessorMixin
|
||||
|
||||
from vllm.multimodal.image import convert_image_mode
|
||||
@@ -215,7 +220,7 @@ def video_to_pixel_values_internvl(
|
||||
return pixel_values
|
||||
|
||||
|
||||
class InternVLImageProcessor:
|
||||
class InternVLImageProcessor(ImageProcessingMixin):
|
||||
def __init__(
|
||||
self,
|
||||
image_size: int,
|
||||
@@ -312,7 +317,7 @@ class InternVLImageProcessor:
|
||||
return BatchFeature(image_inputs, tensor_type=return_tensors)
|
||||
|
||||
|
||||
class InternVLVideoProcessor:
|
||||
class InternVLVideoProcessor(BaseVideoProcessor):
|
||||
def __init__(
|
||||
self,
|
||||
image_size: int,
|
||||
|
||||
@@ -7,7 +7,12 @@ import numpy as np
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
from PIL import Image
|
||||
from transformers import BatchFeature, ProcessorMixin, TensorType
|
||||
from transformers import (
|
||||
BatchFeature,
|
||||
ImageProcessingMixin,
|
||||
ProcessorMixin,
|
||||
TensorType,
|
||||
)
|
||||
from transformers.processing_utils import ProcessingKwargs
|
||||
from typing_extensions import Unpack
|
||||
|
||||
@@ -322,7 +327,7 @@ class IsaacProcessorKwargs(ProcessingKwargs, total=False): # type: ignore[call-
|
||||
}
|
||||
|
||||
|
||||
class IsaacImageProcessor:
|
||||
class IsaacImageProcessor(ImageProcessingMixin):
|
||||
model_input_names = ["pixel_values", "image_grid_thw"]
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -268,7 +268,7 @@ class MiniCPMOProcessor(ProcessorMixin):
|
||||
def batch_decode(self, *args, **kwargs):
|
||||
"""
|
||||
This method forwards all its arguments to LlamaTokenizerFast's
|
||||
[`~PreTrainedTokenizer.batch_decode`]. Please refer to the
|
||||
[`~PythonBackend.batch_decode`]. Please refer to the
|
||||
docstring of this method for more information.
|
||||
"""
|
||||
output_ids = args[0]
|
||||
@@ -289,7 +289,7 @@ class MiniCPMOProcessor(ProcessorMixin):
|
||||
def decode(self, *args, **kwargs):
|
||||
"""
|
||||
This method forwards all its arguments to LlamaTokenizerFast's
|
||||
[`~PreTrainedTokenizer.decode`]. Please refer to the docstring
|
||||
[`~PythonBackend.decode`]. Please refer to the docstring
|
||||
of this method for more information.
|
||||
"""
|
||||
result = args[0]
|
||||
|
||||
@@ -56,14 +56,9 @@ class MiniCPMVProcessor(ProcessorMixin):
|
||||
image_processor_class = "AutoImageProcessor"
|
||||
tokenizer_class = "AutoTokenizer"
|
||||
|
||||
def __init__(self, image_processor=None, tokenizer=None):
|
||||
def __init__(self, image_processor=None, tokenizer=None, version=None):
|
||||
super().__init__(image_processor, tokenizer)
|
||||
# Newer (transformers v5.7+) MiniCPM-V image processors, e.g.
|
||||
# MiniCPMV4_6ImageProcessor, no longer carry a `version` attribute.
|
||||
# Fall back to None instead of hard-crashing: `version` is only used
|
||||
# to special-case the 2.5 tokenization path in `_convert`, and any
|
||||
# value other than 2.5 takes the default branch anyway.
|
||||
self.version = getattr(image_processor, "version", None)
|
||||
self.version = version
|
||||
|
||||
def __call__(
|
||||
self,
|
||||
@@ -100,7 +95,7 @@ class MiniCPMVProcessor(ProcessorMixin):
|
||||
def batch_decode(self, *args, **kwargs):
|
||||
"""
|
||||
This method forwards all its arguments to LlamaTokenizerFast's
|
||||
[`~PreTrainedTokenizer.batch_decode`]. Please refer to the
|
||||
[`~PythonBackend.batch_decode`]. Please refer to the
|
||||
docstring of this method for more information.
|
||||
"""
|
||||
output_ids = args[0]
|
||||
@@ -133,7 +128,7 @@ class MiniCPMVProcessor(ProcessorMixin):
|
||||
def decode(self, *args, **kwargs):
|
||||
"""
|
||||
This method forwards all its arguments to LlamaTokenizerFast's
|
||||
[`~PreTrainedTokenizer.decode`]. Please refer to the docstring
|
||||
[`~PythonBackend.decode`]. Please refer to the docstring
|
||||
of this method for more information.
|
||||
"""
|
||||
result = args[0]
|
||||
@@ -161,7 +156,7 @@ class MiniCPMVProcessor(ProcessorMixin):
|
||||
|
||||
def _convert(self, input_str, max_inp_length: int | None = None):
|
||||
add_bos = getattr(self.tokenizer, "add_bos_token", False)
|
||||
if self.version == 2.5 or add_bos:
|
||||
if self.version == (2, 5) or add_bos:
|
||||
input_ids = self.tokenizer.encode(input_str)
|
||||
else:
|
||||
bos_id = getattr(
|
||||
|
||||
@@ -195,7 +195,7 @@ class Moondream3Processor(ProcessorMixin):
|
||||
The moondream3 model uses a custom tokenizer from 'moondream/starmie-v1'
|
||||
instead of having tokenizer files in the model repo.
|
||||
"""
|
||||
from transformers import AutoTokenizer, PreTrainedTokenizerFast
|
||||
from transformers import AutoTokenizer, TokenizersBackend
|
||||
from transformers.utils import cached_file
|
||||
|
||||
tokenizer = kwargs.pop("tokenizer", None)
|
||||
@@ -237,7 +237,7 @@ class Moondream3Processor(ProcessorMixin):
|
||||
"tokenizer.json",
|
||||
**cached_file_kwargs,
|
||||
)
|
||||
return PreTrainedTokenizerFast(
|
||||
return TokenizersBackend(
|
||||
tokenizer_file=tokenizer_file,
|
||||
clean_up_tokenization_spaces=False,
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import Any
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image
|
||||
from transformers.processing_utils import ProcessorMixin
|
||||
from transformers import ImageProcessingMixin, ProcessorMixin
|
||||
|
||||
IMAGENET_MEAN = np.array([0.484375, 0.455078125, 0.40625], dtype=np.float32)
|
||||
IMAGENET_STD = np.array([0.228515625, 0.2236328125, 0.224609375], dtype=np.float32)
|
||||
@@ -65,7 +65,7 @@ def preprocess_openvla_image(image: Any, image_size: int) -> torch.Tensor:
|
||||
return torch.from_numpy(pixel_values)
|
||||
|
||||
|
||||
class OpenVLAImageProcessor:
|
||||
class OpenVLAImageProcessor(ImageProcessingMixin):
|
||||
def __init__(self, *, image_size: int) -> None:
|
||||
self.image_size = image_size
|
||||
|
||||
|
||||
@@ -417,14 +417,14 @@ class OvisProcessor(ProcessorMixin):
|
||||
|
||||
def batch_decode(self, *args, **kwargs):
|
||||
"""
|
||||
This method forwards all its arguments to Qwen2TokenizerFast's [`~PreTrainedTokenizer.batch_decode`]. Please
|
||||
This method forwards all its arguments to Qwen2TokenizerFast's [`~PythonBackend.batch_decode`]. Please
|
||||
refer to the docstring of this method for more information.
|
||||
"""
|
||||
return self.tokenizer.batch_decode(*args, **kwargs)
|
||||
|
||||
def decode(self, *args, **kwargs):
|
||||
"""
|
||||
This method forwards all its arguments to Qwen2TokenizerFast's [`~PreTrainedTokenizer.decode`]. Please refer to
|
||||
This method forwards all its arguments to Qwen2TokenizerFast's [`~PythonBackend.decode`]. Please refer to
|
||||
the docstring of this method for more information.
|
||||
"""
|
||||
return self.tokenizer.decode(*args, **kwargs)
|
||||
|
||||
@@ -4,13 +4,13 @@ import torch
|
||||
from mistral_common.protocol.instruct.chunk import ImageChunk
|
||||
from mistral_common.tokens.tokenizers.multimodal import ImageEncoder
|
||||
from PIL import Image
|
||||
from transformers import BatchFeature, ProcessorMixin, TensorType
|
||||
from transformers import BatchFeature, ImageProcessingMixin, ProcessorMixin, TensorType
|
||||
from transformers.image_utils import ImageInput
|
||||
|
||||
from vllm.tokenizers.mistral import MistralTokenizer
|
||||
|
||||
|
||||
class MistralCommonImageProcessor:
|
||||
class MistralCommonImageProcessor(ImageProcessingMixin):
|
||||
"""
|
||||
Provide a HF-compatible interface for
|
||||
`mistral_common.tokens.tokenizers.multimodal.ImageEncoder`.
|
||||
|
||||
@@ -8,7 +8,12 @@ import torch
|
||||
from PIL import Image
|
||||
from torchvision import transforms
|
||||
from torchvision.transforms.functional import InterpolationMode
|
||||
from transformers import BatchFeature, ProcessorMixin, TensorType
|
||||
from transformers import (
|
||||
BatchFeature,
|
||||
ImageProcessingMixin,
|
||||
ProcessorMixin,
|
||||
TensorType,
|
||||
)
|
||||
|
||||
from vllm.tokenizers import TokenizerLike
|
||||
|
||||
@@ -240,7 +245,7 @@ class ImagePatcher:
|
||||
)
|
||||
|
||||
|
||||
class Step3VLImageProcessor:
|
||||
class Step3VLImageProcessor(ImageProcessingMixin):
|
||||
def __init__(
|
||||
self,
|
||||
image_size: int = 728,
|
||||
|
||||
@@ -6,13 +6,18 @@ from math import ceil
|
||||
import numpy as np
|
||||
import torch
|
||||
from mistral_common.tokens.tokenizers.audio import AudioEncoder
|
||||
from transformers import BatchFeature, ProcessorMixin, TensorType
|
||||
from transformers import (
|
||||
BatchFeature,
|
||||
ProcessorMixin,
|
||||
SequenceFeatureExtractor,
|
||||
TensorType,
|
||||
)
|
||||
from transformers.audio_utils import AudioInput
|
||||
|
||||
from vllm.tokenizers.mistral import MistralTokenizer
|
||||
|
||||
|
||||
class MistralCommonFeatureExtractor:
|
||||
class MistralCommonFeatureExtractor(SequenceFeatureExtractor):
|
||||
"""
|
||||
Provide a HF-compatible interface for
|
||||
`mistral_common.tokens.tokenizers.multimodal.AudioEncoder`.
|
||||
|
||||
Reference in New Issue
Block a user