Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于计算MAE等的问题 #85

Open
muyiyiyi opened this issue Nov 26, 2020 · 1 comment
Open

关于计算MAE等的问题 #85

muyiyiyi opened this issue Nov 26, 2020 · 1 comment

Comments

@muyiyiyi
Copy link

作者的模型网络输出密度图的宽高都是原始图像的1/8,以256256的图像为例,网络预测的密度图是3232大小,但是相对于真实值密度图256*256,它俩的像素值之和(人数)应该是64倍的差异啊,计算MAE的时候,应该网络预测的密度图值乘以64再与原始密度图像素和进行比较吧,为什么val.ipynb文件中,直接使用网络输出的密度图与原始标签进行比较。

# 计算mae的代码
mae += abs(output.detach().cpu().sum().numpy()-np.sum(groundtruth))

# 真实密度图标签的生成代码
k = np.zeros((img.shape[0],img.shape[1]))  # 密度图与原始图像尺寸一致
gt = mat["image_info"][0,0][0,0][0]
for i in range(0,len(gt)):
    if int(gt[i][1])<img.shape[0] and int(gt[i][0])<img.shape[1]:
        k[int(gt[i][1]),int(gt[i][0])]=1
k = gaussian_filter_density(k)
with h5py.File(img_path.replace('.jpg','.h5').replace('images','ground_truth'), 'w') as hf:
        hf['density'] = k

还是说,需要修改代码,让预测图上采样回到与原始图像尺寸一致吗?

@muyiyiyi
Copy link
Author

不好意思。。我看到load_data的源码了。原来是将真实值缩小,像素值乘以64从而保持尺寸对应和人数不变。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant