模型名称: TianheWu/VisualQuality-R1-7B
模型链接: HuggingFace
模型描述: VisualQuality-R1-7B 是一个基于 Qwen2.5-VL 架构的视觉质量评估模型,能够对输入图像进行质量评分和分析。
模型架构: Qwen2.5-VL (Vision-Language Model)
参数规模: ~8.3B
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.51.0 | HuggingFace Transformers(实测 4.57.6) |
| accelerate | >= 0.25.0 | 用于 device_map 自动分配 |
| Pillow | >= 9.0 | 图像处理 |
| numpy | >= 1.24 | 数值计算 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch-npu transformers accelerate Pillow numpy# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐,需配置镜像)
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download TianheWu/VisualQuality-R1-7B --local-dir ./VisualQuality-R1-7B方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
huggingface-cli download https://ai.gitcode.com/hf_mirrors/TianheWu/VisualQuality-R1-7B --local-dir ./VisualQuality-R1-7B# 使用 inference.py 运行推理
python3 inference.py --model-path ./VisualQuality-R1-7B
# 指定输入图像和问题
python3 inference.py --model-path ./VisualQuality-R1-7B --image test.jpg --question "Rate the quality of this image on a scale of 1-10."
# 指定 NPU 设备和生成长度
python3 inference.py --model-path ./VisualQuality-R1-7B --device 0 --max-new-tokens 512| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --image | str | None | 输入图像路径(None 则使用随机测试图) |
| --question | str | "Rate the quality..." | 关于图像的问题 |
| --max-new-tokens | int | 512 | 最大生成长度 |
| --device | int | 0 | NPU 设备编号 |
[模型] TianheWu/VisualQuality-R1-7B
[设备] NPU:0 (Ascend910_9362)
[输入] 使用随机测试图像 (224x224)
[输出] The quality of the image is very poor, with a score of 1 out of 10...
[耗时] 56.61s
[状态] SUCCESS运行命令:
python3 inference.py --model-path /tmp/adapt_tianhewu_visualquality-r1-7b/weights输出:
[设备] NPU:0 (Ascend910_9362)
[加载] 加载模型: /tmp/adapt_tianhewu_visualquality-r1-7b/weights
[输入] 使用随机测试图像 (224x224)
[推理] 生成中 (max_new_tokens=512)...
[输出] The quality of the image is very poor, with a score of 1 out of 10. The image appears to be heavily pixelated and lacks any discernible content or clarity. It is not possible to make out any details or features in the image due to the extreme pixelation.
[耗时] 56.61s
[状态] SUCCESS


测试数据: 随机生成的 224x224 测试图像
评测指标:
| 指标 | 结果 | 说明 |
|---|---|---|
| 模型加载时间 | ~93s (729 shards) | 首次加载权重 |
| 单次推理耗时 | 56.61s | 含模型加载+预处理+生成 |
| 生成质量 | SUCCESS | 模型正常输出评估文本 |
评测命令:
python3 inference.py --model-path /tmp/adapt_tianhewu_visualquality-r1-7b/weights无