Adapted-Center-and-Scale-Prediction icon indicating copy to clipboard operation
Adapted-Center-and-Scale-Prediction copied to clipboard

测试代码中,输入模型的图片和后处理的图片尺度不匹配

Open Gs928 opened this issue 3 years ago • 13 comments

for i, data in enumerate(testloader, 0): inputs = data.cuda() 您好,在test.py中,读取测试testloader时,input尺寸大小为(1024,2048)。但是在后处理部分,函数 parse_det_offset(r, pos.cpu().numpy(), height.cpu().numpy(), offset.cpu().numpy(), config.size_test, score=0.1, down=4, nms_thresh=0.5) 使用的图片大小为(1280, 2560),出现了图片大小不对应,为什么要这样处理呢

Gs928 avatar Jun 10 '21 03:06 Gs928

没太看懂是哪里不匹配

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Gs928 @.> 发送时间: 2021年6月10日 11:28 收件人: WangWenhao0716/Adapted-Center-and-Scale-Prediction @.> 抄送: Subscribed @.***> 主题: 回复:[WangWenhao0716/Adapted-Center-and-Scale-Prediction] 测试代码种,输入模型的图片和后处理的图片尺度不匹配 (#19)

WangWenhao0716 avatar Jun 10 '21 03:06 WangWenhao0716

for i, data in enumerate(testloader, 0):
    inputs = data.cuda()
    with torch.no_grad():
        pos, height, offset = net(inputs)

    boxes = parse_det_offset(r, pos.cpu().numpy(), height.cpu().numpy(), offset.cpu().numpy(), config.size_test, score=0.1, down=4, nms_thresh=0.5)
    if len(boxes) > 0:
        boxes[:, [2, 3]] -= boxes[:, [0, 1]]

        for box in boxes:
            temp = dict()
            temp['image_id'] = i+1
            temp['category_id'] = 1
            temp['bbox'] = box[:4].tolist()
            temp['score'] = float(box[4])
            res.append(temp)

上述代码中的inputs的size和parse_det_offset函数传入的 config.size_test,不一致

Gs928 avatar Jun 10 '21 04:06 Gs928

你这样print一下,应该匹配

print(inputs.shape)
print(config.size_test) 

WangWenhao0716 avatar Jun 10 '21 04:06 WangWenhao0716

print(input.shape)-->torch.Size([1, 3, 1024, 2048]) print(config.size_test)-->(1280, 2560) 我打断点也试过了,确实不一致

Gs928 avatar Jun 10 '21 04:06 Gs928

不错,感谢指出,这个可能是个bug

发自我的 iPad

------------------ 原始邮件 ------------------ 发件人: Gs928 @.> 发送时间: 2021年6月10日 12:34 收件人: WangWenhao0716/Adapted-Center-and-Scale-Prediction @.> 抄送: Wenhao Wang @.>, Comment @.> 主题: 回复:[WangWenhao0716/Adapted-Center-and-Scale-Prediction] 测试代码中,输入模型的图片和后处理的图片尺度不匹配 (#19)

print(input.shape)-->torch.Size([1, 3, 1024, 2048]) print(config.size_test)-->(1280, 2560) 我打断点也试过了,确实不一致

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

WangWenhao0716 avatar Jun 10 '21 04:06 WangWenhao0716

我想请教一下,您设计的初衷是想要让test阶段的size变为(1280, 2560)呢,还是就保持(1024, 2048)

Gs928 avatar Jun 10 '21 04:06 Gs928

保持1024 2048

发自我的 iPad

------------------ 原始邮件 ------------------ 发件人: Gs928 @.> 发送时间: 2021年6月10日 12:37 收件人: WangWenhao0716/Adapted-Center-and-Scale-Prediction @.> 抄送: Wenhao Wang @.>, Comment @.> 主题: 回复:[WangWenhao0716/Adapted-Center-and-Scale-Prediction] 测试代码中,输入模型的图片和后处理的图片尺度不匹配 (#19)

我想请教一下,您设计的初衷是想要让test阶段的size变为(1280, 2560)呢,还是就保持(1024, 2048)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

WangWenhao0716 avatar Jun 10 '21 05:06 WangWenhao0716

这个其实我没注意到;我觉得这两个setting没区别。但不应该同时出现两个不同的

发自我的 iPad

------------------ 原始邮件 ------------------ 发件人: Gs928 @.> 发送时间: 2021年6月10日 12:37 收件人: WangWenhao0716/Adapted-Center-and-Scale-Prediction @.> 抄送: Wenhao Wang @.>, Comment @.> 主题: 回复:[WangWenhao0716/Adapted-Center-and-Scale-Prediction] 测试代码中,输入模型的图片和后处理的图片尺度不匹配 (#19)

我想请教一下,您设计的初衷是想要让test阶段的size变为(1280, 2560)呢,还是就保持(1024, 2048)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

WangWenhao0716 avatar Jun 10 '21 05:06 WangWenhao0716

嗯嗯,如果size保持1024 2048,指标略有变化,不过影响不大

Gs928 avatar Jun 10 '21 06:06 Gs928

那这两个size哪个得到的结果好一点呀

yaru-w avatar Jun 11 '21 14:06 yaru-w

我这边没实验过

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: yaru-w @.> 发送时间: 2021年6月11日 22:40 收件人: WangWenhao0716/Adapted-Center-and-Scale-Prediction @.> 抄送: Wenhao Wang @.>, Comment @.> 主题: 回复:[WangWenhao0716/Adapted-Center-and-Scale-Prediction] 测试代码中,输入模型的图片和后处理的图片尺度不匹配 (#19)

WangWenhao0716 avatar Jun 11 '21 14:06 WangWenhao0716

(1280, 2560)这种尺寸我没试验过,但是保持1024 2048会使得结果略有改善。

Gs928 avatar Jun 15 '21 01:06 Gs928

不错

发自我的 iPad

------------------ 原始邮件 ------------------ 发件人: Gs928 @.> 发送时间: 2021年6月15日 10:00 收件人: WangWenhao0716/Adapted-Center-and-Scale-Prediction @.> 抄送: Wenhao Wang @.>, Comment @.> 主题: 回复:[WangWenhao0716/Adapted-Center-and-Scale-Prediction] 测试代码中,输入模型的图片和后处理的图片尺度不匹配 (#19)

(1280, 2560)这种尺寸我没试验过,但是保持1024 2048会使得结果略有改善。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

WangWenhao0716 avatar Jun 15 '21 02:06 WangWenhao0716