VisualQuality-R1 是首个通过 RL2R (Reinforcement Learning to Rank) 增强的无参考图像质量评估 (NR-IQA) 模型,支持基于推理的质量描述与评分。本仓库为该模型在昇腾 Ascend910 平台的 torch-npu 适配版本。
Qwen/Qwen2.5-VL-7B-Instructnpu:N),bf16,单卡推理| 组件 | 版本 |
|---|---|
| Python | 3.11 |
| torch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| transformers | 4.57.6 |
| CANN | 8.5.1 |
权重缓存于 ./model_weights/VisualQuality-R1-7B/(约 16.6GB,4 个 safetensors 分片)。首次运行 inference.py 时会自动从 hf-mirror.com 下载并缓存;已缓存则直接复用,避免重复下载。
python inference.py --img test_input.png --device npu:1输出 JSON(含 rating_text 与 score):
{
"model": "VisualQuality-R1-7B",
"score": 4.05,
"rating_text": "<answer>4.05</answer>",
"actual_device": "npu:1",
"exit_status": 0
}python inference.py --serve --port 8000curl -F "file=@test_input.png" http://127.0.0.1:8000/predictYou are doing the image quality assessment task. Here is the question:
What is your overall rating on the quality of this picture? The rating should
be a float between 1 and 5, rounded to two decimal places, with 1 representing
very poor quality and 5 representing excellent quality.问题模板:{Question} Please only output the final answer with only one score in <answer> </answer> tags.
npu:N。attn_implementation="eager",不依赖 flash-attn。torch.npu.empty_cache() 释放显存(bf16 7B 约 14GB,单卡 64GB 足够)。