当前位置: 首页 > web >正文

vllm部署--Qwen2.5VL-7B

model

Qwen/Qwen2.5-VL-7B-Instruct

pytorch:

2.4.0+cu118

flash-attn

选择合适的版本,直接pip安装总是出错:
https://github.com/Dao-AILab/flash-attention/releases?page=2

flash-attn 版本 2.7.0.post1

requirements

accelerate==1.1.0
av==14.3.0
huggingface-hub==0.30.2
modelscope==1.25.0
scikit-image==0.24.0
requests==2.32.3
tokenizers==0.21.1
transformers==4.49.0
xformers==0.0.27.post2

测试代码

import torch
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
from qwen_vl_utils import process_vision_info# We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
model = Qwen2_5_VLForConditionalGeneration.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct",torch_dtype=torch.bfloat16,attn_implementation="flash_attention_2",device_map="auto",
)# The default range for the number of visual tokens per image in the model is 4-16384.
# You can set min_pixels and max_pixels according to your needs, such as a token range of 256-1280, to balance performance and cost.
min_pixels = 128*28*28
max_pixels = 512*28*28
processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels)messages = [{"role": "user","content": [{"type": "image","image": "./1745224698785.jpg",},{"type": "text", "text": "请描述一下这幅图像。"},],}
]# Preparation for inference
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True
)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(text=[text],images=image_inputs,videos=video_inputs,padding=True,return_tensors="pt",
)
inputs = inputs.to("cuda")# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=256)
generated_ids_trimmed = [out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
]
output_text = processor.batch_decode(generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
)
print(output_text)
http://www.xdnf.cn/news/3246.html

相关文章:

  • SpringMVC框架(一)
  • Tomcat 服务频繁崩溃的排查与解决方法
  • 【人工智能】解锁边缘智能:Ollama 模型压缩技术与 DeepSeek 边缘部署深度解析
  • Excel 数组功能及应用示例
  • SQL实战:05之间隔连续数问题求解
  • 安全企业内部im,BeeWorks即时通讯
  • boost 编译(windows10 + mingw7.3.0)
  • EWM 流程全自动化实现方法
  • 华为发布全球首个L3商用智驾ADS4.0
  • SpringBoot 设置HTTP代理访问
  • Wartales 战争传说 [DLC 解锁] [Steam] [Windows SteamOS]
  • transformers库里model.generate和model.forward的区别 generate函数里不同的解码方式
  • 【MyBatis-Plus】禁用某个方法里面查询语句的逻辑删除标记
  • Java 中的 设计模式详解
  • errorno 和WSAGetlasterror的区别
  • 潇洒郎: 100% 成功搭建Docker私有镜像仓库并管理、删除镜像
  • Pytorch深度学习框架60天进阶学习计划 - 第55天:3D视觉基础(一)
  • 【人工智能】释放本地AI潜能:LM Studio用户脚本自动化DeepSeek的实战指南
  • (A2A Agent通信故障诊断体系)
  • Spring Boot 数据库最佳实践:从自动配置到高性能优化
  • 腾讯云CodeBuddy初体验
  • 从边缘到云端:边缘计算与云计算的协同未来
  • OpenCV-Python (官方)中文教程(部分一)_Day20
  • Elastic Security 8.18 和 9.0 中的新功能
  • Vue 3 动态组件
  • PostgreSQL可串行化快照隔离和冻结处理
  • 农产品园区展示系统——仙盟创梦IDE开发
  • 《PyTorch documentation》(PyTorch 文档)
  • vscode 个性化
  • 通过API网关防御重放攻击:技术方案与实战验证