[VLM] Use SequenceData.from_token_counts to create dummy data (#8687)
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Inference-only Qwen2-VL model compatible with HuggingFace weights."""
|
||||
from array import array
|
||||
from functools import lru_cache, partial
|
||||
from typing import (Iterable, List, Mapping, Optional, Tuple, Type, TypedDict,
|
||||
Union)
|
||||
@@ -66,8 +65,7 @@ from vllm.multimodal import (MULTIMODAL_REGISTRY, MultiModalDataDict,
|
||||
from vllm.multimodal.base import MultiModalData
|
||||
from vllm.multimodal.image import cached_get_image_processor
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.sequence import (VLLM_TOKEN_ID_ARRAY_TYPE, IntermediateTensors,
|
||||
SequenceData)
|
||||
from vllm.sequence import IntermediateTensors, SequenceData
|
||||
from vllm.transformers_utils.processor import get_processor
|
||||
|
||||
logger = init_logger(__name__)
|
||||
@@ -681,15 +679,14 @@ def dummy_data_for_qwen2_vl(
|
||||
"--limit-mm-per-prompt.")
|
||||
|
||||
hf_config = ctx.get_hf_config(Qwen2VLConfig)
|
||||
token_ids = array(VLLM_TOKEN_ID_ARRAY_TYPE,
|
||||
[hf_config.vision_start_token_id])
|
||||
token_ids += array(VLLM_TOKEN_ID_ARRAY_TYPE,
|
||||
[hf_config.image_token_id]) * max_llm_image_tokens
|
||||
token_ids += array(VLLM_TOKEN_ID_ARRAY_TYPE,
|
||||
[hf_config.vision_end_token_id])
|
||||
token_ids += array(VLLM_TOKEN_ID_ARRAY_TYPE,
|
||||
[0]) * (seq_len - max_llm_image_tokens - 2)
|
||||
dummy_seqdata = SequenceData(token_ids)
|
||||
|
||||
dummy_seqdata = SequenceData.from_token_counts(
|
||||
(hf_config.vision_start_token_id, 1),
|
||||
(hf_config.image_token_id, max_llm_image_tokens),
|
||||
(hf_config.vision_end_token_id, 1),
|
||||
(0, seq_len - max_llm_image_tokens - 2),
|
||||
)
|
||||
|
||||
dummy_image = Image.new("RGB", (max_resized_width, max_resized_height),
|
||||
color=0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user