[Chore] Use Transformers v5 names and drop redundant processor use_fast (#58550)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
484c211fe8
commit
d881812500
@@ -4,12 +4,12 @@
|
||||
# Adapted from
|
||||
# https://github.com/zai-org/CogAgent
|
||||
from transformers import PythonBackend
|
||||
from transformers.image_processing_utils_fast import BaseImageProcessorFast
|
||||
from transformers.image_processing_backends import TorchvisionBackend
|
||||
from transformers.image_utils import PILImageResampling
|
||||
from transformers.processing_utils import ProcessorMixin
|
||||
|
||||
|
||||
class GLM4VImageProcessorFast(BaseImageProcessorFast):
|
||||
class GLM4VImageProcessorFast(TorchvisionBackend):
|
||||
"""Port of https://huggingface.co/zai-org/glm-4v-9b/blob/main/tokenization_chatglm.py#L177
|
||||
to HF Transformers.
|
||||
"""
|
||||
|
||||
@@ -7,12 +7,12 @@ import math
|
||||
import numpy as np
|
||||
import torch
|
||||
from torchvision.transforms.v2 import functional as tvF
|
||||
from transformers.image_processing_utils import BatchFeature
|
||||
from transformers.image_processing_utils_fast import (
|
||||
BaseImageProcessorFast,
|
||||
from transformers.image_processing_backends import (
|
||||
TorchvisionBackend,
|
||||
group_images_by_shape,
|
||||
reorder_images,
|
||||
)
|
||||
from transformers.image_processing_utils import BatchFeature
|
||||
from transformers.image_utils import (
|
||||
OPENAI_CLIP_MEAN,
|
||||
OPENAI_CLIP_STD,
|
||||
@@ -327,7 +327,7 @@ class Glm5NextImageProcessorKwargs(ImagesKwargs, total=False): # type: ignore[c
|
||||
max_image_tokens: int | None
|
||||
|
||||
|
||||
class Glm5NextImageProcessor(BaseImageProcessorFast):
|
||||
class Glm5NextImageProcessor(TorchvisionBackend):
|
||||
"""Fast torchvision image processor for GLM-5.3-Flash.
|
||||
|
||||
``patch_expand_factor`` multiplies into the ``smart_resize`` spatial
|
||||
@@ -759,7 +759,7 @@ class Glm5NextProcessor(ProcessorMixin):
|
||||
attributes = ["image_processor", "tokenizer", "video_processor"]
|
||||
image_processor_class = "AutoImageProcessor"
|
||||
video_processor_class = "AutoVideoProcessor"
|
||||
tokenizer_class = ("PreTrainedTokenizer", "PreTrainedTokenizerFast")
|
||||
tokenizer_class = ("PythonBackend", "TokenizersBackend")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -18,8 +18,8 @@ import math
|
||||
import torch
|
||||
from torchvision.transforms import InterpolationMode
|
||||
from transformers import AutoTokenizer, BatchFeature
|
||||
from transformers.image_processing_utils_fast import (
|
||||
BaseImageProcessorFast,
|
||||
from transformers.image_processing_backends import (
|
||||
TorchvisionBackend,
|
||||
group_images_by_shape,
|
||||
reorder_images,
|
||||
)
|
||||
@@ -156,7 +156,7 @@ class MiniMaxM3VLImageProcessorKwargs(ImagesKwargs, total=False): # type: ignor
|
||||
max_long_side_pixel: int
|
||||
|
||||
|
||||
class MiniMaxM3VLImageProcessor(BaseImageProcessorFast):
|
||||
class MiniMaxM3VLImageProcessor(TorchvisionBackend):
|
||||
do_resize = True
|
||||
resample = PILImageResampling.BICUBIC
|
||||
# required by base-class validation, not used as the resize bound
|
||||
|
||||
@@ -437,7 +437,7 @@ class MuseGlimmerProcessor(ProcessorMixin):
|
||||
attributes = ["image_processor", "video_processor", "tokenizer"]
|
||||
image_processor_class = "AutoImageProcessor"
|
||||
video_processor_class = "AutoVideoProcessor"
|
||||
tokenizer_class = "PreTrainedTokenizerFast"
|
||||
tokenizer_class = "TokenizersBackend"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -20,7 +20,7 @@ import numpy.typing as npt
|
||||
import regex as re
|
||||
import torch
|
||||
from PIL import Image
|
||||
from transformers import BatchFeature, PretrainedConfig, TensorType
|
||||
from transformers import BatchFeature, PreTrainedConfig, TensorType
|
||||
|
||||
from vllm.model_executor.models.parakeet import ParakeetExtractor
|
||||
from vllm.multimodal.inputs import AudioItem
|
||||
@@ -584,7 +584,7 @@ class BaseNanoNemotronVLProcessor(ABC):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
config: PretrainedConfig,
|
||||
config: PreTrainedConfig,
|
||||
tokenizer: HfTokenizer,
|
||||
*args,
|
||||
max_model_len: int,
|
||||
@@ -623,7 +623,7 @@ class BaseNanoNemotronVLProcessor(ABC):
|
||||
self.dtype: torch.dtype = getattr(config, "dtype", torch.float32)
|
||||
|
||||
@staticmethod
|
||||
def use_dynamic_resolution(config: PretrainedConfig) -> bool:
|
||||
def use_dynamic_resolution(config: PreTrainedConfig) -> bool:
|
||||
return "min_num_patches" in config.vision_config.args
|
||||
|
||||
@property
|
||||
@@ -771,7 +771,7 @@ class NanoNemotronVLProcessor(BaseNanoNemotronVLProcessor):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
config: PretrainedConfig,
|
||||
config: PreTrainedConfig,
|
||||
tokenizer: HfTokenizer,
|
||||
*,
|
||||
max_model_len: int,
|
||||
|
||||
Reference in New Issue
Block a user