The Qwen2.5-VL multimodal image understanding model supports visual semantic parsing and natural language description generation, making it suitable for a variety of image analysis scenarios.
prompt parameter to meet diverse business requirements.bfloat16, float16, and float32 precision, fully utilizing GPU computing power.Input column name | Note |
|---|---|
images | An array containing image data, with element types as string or binary data. |
user_prompts | The prompt corresponding to image understanding. Defaults to None. If not provided, the prompt parameter will be used by default. |
The processed array, with each element representing the understanding result for each image.
If a parameter does not have a default value, it is required.
Parameter name | Type | Default value | Description |
|---|---|---|---|
image_src_type | str | image_url | The format type of the input image. Supported: - "image_url": TOS (Object Storage Service)/HTTP address - "image_base64": base64 encoding - "image_binary": binary stream Optional values: ["image_url", "image_base64", "image_binary"] Default value: "image_url" |
model_path | str | /opt/las/models | The absolute path for storing local model files. Defaults to the preset path inside the container. When using a custom model, this path needs to be modified. Default value: "/opt/las/models" |
model_name | str | Qwen/Qwen2.5-VL-7B-Instruct | Supported visual language model versions. Currently, only Qwen2.5-VL series models are supported. Optional values: ["Qwen/Qwen2.5-VL-7B-Instruct-AWQ", "Qwen/Qwen2.5-VL-7B-Instruct", "Qwen/Qwen2.5-VL-32B-Instruct-AWQ", "Qwen/Qwen2.5-VL-32B-Instruct", "Qwen/Qwen2.5-VL-72B-Instruct"] Default value: "Qwen/Qwen2.5-VL-7B-Instruct" |
prompt | str | Please provide a detailed description of this image. | Prompt words help users understand the video content, and the model generates a description of the video based on these prompts. If set to empty, it is recommended to provide a specific prompt for each data entry. Default value: "Please provide a detailed description of this video." |
batch_size | int | 4 | Number of samples processed per inference. A larger batch_size increases throughput but also raises GPU memory consumption. It is recommended to adjust according to GPU memory capacity. Default value: 4 |
dtype | str | bfloat16 | Model inference precision selection. - "bfloat16": Balances precision and speed - "float16": Faster inference speed - "float32": Highest precision but maximum GPU memory consumption Optional values: ["bfloat16", "float16", "float32"] Default value: "bfloat16" |
max_model_len | int | 128000 | Maximum supported model input length (number of tokens), affects the length of video descriptions that can be processed, cannot exceed 128000. Default value: 128000 |
max_num_seqs | int | 128 | Maximum number of sequences per batch, affects concurrent inference capability. Default value: 128 |
tensor_parallel_size | int | 1 | Number of GPUs used for tensor parallelism, increases inference speed. Default value: 1 |
enable_prefix_caching | bool | True | Whether to enable prefix caching to accelerate multi-turn inference. Default value: True |
gpu_memory_utilization | float | 0.9 | Upper limit for single GPU memory utilization, range 0~1. Default value: 0.9 |
enforce_eager | bool | False | Whether to force the use of eager mode for inference, available for debugging or special scenarios. Default value: False |
resized_height | int or None | None | Image height. If not set, the original image height is used by default. The higher the image height, the greater the GPU memory usage. Default value: None |
resized_width | int or None | None | Image width. If not set, the original image width is used by default. The greater the image width, the higher the GPU memory usage. Default value: None |
temperature | float | 1.0 | Sampling temperature, controls the diversity of generated content. The higher the value, the more random the generation. Default value: 1.0 |
top_p | float | 0.2 | Nucleus sampling probability threshold, controls the diversity of generated content. The smaller the value, the more conservative the generation. Default value: 0.2 |
repetition_penalty | float | 1.05 | Repetition penalty coefficient, prevents generation of repeated content. The larger the value, the less repeated content is generated. Default value: 1.05 |
max_tokens | int | 8192 | Maximum number of tokens generated per run, affects description length. Default value: 8192 |
stop_token_ids | list | [] | Generation stops when these token IDs are encountered. Used to customize generation termination conditions. Default value: [] |
seed | int | 42 | Random seed, ensures inference results are reproducible. Default value: 42 |
The following code demonstrates how to use daft to run the operator for image content understanding and generate descriptions according to instructions.
from __future__ import annotations import logging import os import ray import daft from daft import col from daft.las.functions.multimodal.qwen_vl_image_understanding_vllm import QwenVLImageUnderstandingVLLM from daft.las.functions.udf import las_udf if __name__ == "__main__": os.environ["DAFT_RUNNER"] = "ray" def configure_logging(): logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S.%s".format(), ) logging.getLogger("tracing.span").setLevel(logging.WARNING) logging.getLogger("daft_io.stats").setLevel(logging.WARNING) logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING) ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging}) daft.set_runner_ray() daft.set_execution_config(actor_udf_ready_timeout=600) daft.set_execution_config(min_cpu_per_task=0) tos_dir_url = os.getenv("TOS_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com") samples = { "image_path": [ f"https://{tos_dir_url}/public/shared_image_dataset/cat_ip_adapter.jpeg" ], "prompt": [""], } image_src_type = "image_url" model_path = os.getenv("MODEL_PATH", "/opt/las/models") model_name = os.getenv("MODEL_NAME", "Qwen/Qwen2.5-VL-7B-Instruct") dtype = "bfloat16" default_prompt = None max_caption_length = 256 resized_height = 256 resized_width = 256 batch_size = 2 seed = 42 max_model_len = 12800 max_num_seqs = 128 tensor_parallel_size = 1 enable_prefix_caching = False gpu_memory_utilization = 0.95 enforce_eager = True ds = daft.from_pydict(samples) ds = ds.with_column( "caption", las_udf( QwenVLImageUnderstandingVLLM, construct_args={ "image_src_type": image_src_type, "model_path": model_path, "model_name": model_name, "dtype": dtype, "prompt": default_prompt, "max_caption_length": max_caption_length, "resized_height": resized_height, "resized_width": resized_width, "batch_size": batch_size, "seed": seed, "max_model_len": max_model_len, "max_num_seqs": max_num_seqs, "tensor_parallel_size": tensor_parallel_size, "enable_prefix_caching": enable_prefix_caching, "gpu_memory_utilization": gpu_memory_utilization, "enforce_eager": enforce_eager, }, num_gpus=tensor_parallel_size, batch_size=batch_size, concurrency=1, )(col("image_path"), col("prompt")), ) ds.show() # ╭────────────────────────────────┬─────────────────────────┬─────────────────────────────────────────────────────────────╮ # │ image_path ┆ prompt ┆ caption │ # │ --- ┆ --- ┆ --- │ # │ Utf8 ┆ Utf8 ┆ Utf8 │ # ╞════════════════════════════════╪═════════════════════════╪═════════════════════════════════════════════════════════════╡ # │ https://las-cn-beijing-public… ┆ Please provide a detailed description of the image. … ┆ This image shows an anthropomorphic cat dressed in vintage-style clothing, including a blue garment… │ # ╰────────────────────────────────┴─────────────────────────┴─────────────────────────────────────────────────────────────╯