ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

Qwen3.5的坐标转换问题

Open dong-168 opened this issue 8 months ago • 8 comments

Checklist / 检查清单

  • [x] I have searched existing issues, and this is a new question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。

Question Description / 问题描述

直接将千位数格式的坐标按图像实际尺寸换算,会导致目标框与真实目标位置不匹配。 怎么解决?

dong-168 avatar Mar 27 '26 03:03 dong-168

你可以提供一个具体的case吗? 是Grounding本身不准,还是他的格式本来就有问题

MDR-EX1000 avatar Mar 30 '26 04:03 MDR-EX1000

Qwen3.5-4B

情况1: 目标框看似接近标签,但有偏移
图像尺寸:800 x 450 公式:真实坐标 = (千位数 / 1000) × 对应边长 eg.
第 1 个目标框 [580, 388, 670, 738] 580 / 1000 * 800 = 464 388 / 1000 * 450 = 175 670 / 1000 * 800 = 536 738 / 1000 * 450 = 332

序号 标签目标框 (Ground Truth) 模型输出目标框 (Prediction) 转换后目标框
1 [450, 157, 528, 289] [580, 388, 670, 738] [464, 175, 536, 332]
2 [345, 230, 436, 449] [480, 588, 600, 998] [384, 265, 480, 449]

情况2: 有些图像测试时,发现 Grounding 本身不准

所以: 个人倾向 Qwen3.5-4B 的 Grounding 没有优化好。但想知道有没有可能是我坐标转换出了问题(qwen3.5内部进行了图像尺寸调整,后处理时可能需要使用变换后的尺寸,而不是原始图像尺寸)。

@MDR-EX1000

dong-168 avatar Mar 30 '26 07:03 dong-168

https://github.com/vllm-project/vllm/issues/29595 看下有没有可能是这个问题,vllm/triton 版本, 换成eager模式推理试下

MDR-EX1000 avatar Mar 30 '26 08:03 MDR-EX1000

我没有使用vllm推理,采用ms-swift框架的推理,没有设置attn_implementation:

import os
# os.environ['SWIFT_DEBUG'] = '1'
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
os.environ['IMAGE_MAX_TOKEN_NUM'] = '1024'
os.environ['VIDEO_MAX_TOKEN_NUM'] = '128'
os.environ['FPS_MAX_FRAMES'] = '16'

from swift import get_model_processor, get_template
from swift.infer_engine import TransformersEngine, InferRequest, RequestConfig

model, processor = get_model_processor('Qwen/Qwen3.5-4B')  # attn_impl='flash_attention_2'
template = get_template(processor, enable_thinking=False)
engine = TransformersEngine(model, template=template)
infer_request = InferRequest(messages=[{
    "role": "user",
    "content": '<video>Describe this video.',
}], videos=['https://modelscope-open.oss-cn-hangzhou.aliyuncs.com/images/baby.mp4'])
request_config = RequestConfig(max_tokens=128, temperature=0)
resp_list = engine.infer([infer_request], request_config=request_config)
response = resp_list[0].choices[0].message.content
print(response)

# use stream
request_config = RequestConfig(max_tokens=128, temperature=0, stream=True)
gen_list = engine.infer([infer_request], request_config=request_config)
for chunk in gen_list[0]:
    if chunk is None:
        continue
    print(chunk.choices[0].delta.content, end='', flush=True)
print()

@MDR-EX1000

dong-168 avatar Mar 30 '26 09:03 dong-168

@dong-168 用 https://github.com/evolvinglmms-lab/lmms-eval 评估一下osworld 和 screenspot 那几个,按0-1000归一化处理,看起来问题不大。 @MDR-EX1000 想请问3.5有像qwen3-vl时候官方的 gui agent 例子能参考吗

huaiyizhao avatar Mar 30 '26 11:03 huaiyizhao

@dong-168 用 https://github.com/evolvinglmms-lab/lmms-eval 评估一下osworld 和 screenspot 那几个,按0-1000归一化处理,看起来问题不大。 @MDR-EX1000 想请问3.5有像qwen3-vl时候官方的 gui agent 例子能参考吗

我没有找到,不过应该和qwen3vl调用方式是一样的,只是vllm版本需要>0.17.0.

MDR-EX1000 avatar Mar 30 '26 11:03 MDR-EX1000

This issue has been inactive for over 3 months and will be automatically closed in 7 days. If this issue is still relevant, please reply to this message.

github-actions[bot] avatar Jun 29 '26 00:06 github-actions[bot]

This issue has been automatically closed due to inactivity. If needed, it can be reopened.

github-actions[bot] avatar Jul 07 '26 00:07 github-actions[bot]