# SPDX-License-Identifier: Apache-2.0 # Copyright 2025 The vLLM-Omni team. # Copyright 2024 ANT Group and the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from typing import Any import numpy as np import torch from transformers import AutoFeatureExtractor, AutoProcessor from transformers.feature_extraction_utils import BatchFeature, FeatureExtractionMixin from transformers.processing_utils import ProcessorMixin from transformers.tokenization_utils_base import PreTokenizedInput, TextInput from transformers.utils import logging from vllm_omni.transformers_utils.configs.ming_flash_omni import BailingMM2Config try: from transformers import AutoVideoProcessor except ImportError: AutoVideoProcessor = None _HAS_VIDEO_PROCESSOR = AutoVideoProcessor is not None logger = logging.get_logger(__name__) def raise_missing_video_processor(): raise ValueError("Ming Flash Omni video inputs require a Transformers 5.x `video_processor`.") DEFAULT_IMAGE_PATCH_TOKEN = "" DEFAULT_IM_START_TOKEN = "" DEFAULT_IM_END_TOKEN = "" DEFAULT_VID_START_TOKEN = "" DEFAULT_FRAME_PATCH_TOKEN = "" DEFAULT_AUDIO_PATCH_TOKEN = "" DEFAULT_AU_START_TOKEN = "" # High-level placeholders used in user prompts PLACEHOLDER_IMAGE_TOKEN_IN_TEXT = "" PLACEHOLDER_VIDEO_TOKEN_IN_TEXT = "