1 Star 0 Fork 0

zhongdehai/hourglass-facekeypoints-detection

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
evaluation.py 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
Raymon 提交于 2017-12-25 14:45 . first submit
#coding=utf-8
import torch
import numpy as np
from torch.utils.data import DataLoader
from torch.autograd import Variable
import matplotlib.pyplot as plt
from data_loader import KFDataset
from models import KFSGNet
from train import config,get_peak_points,get_mse
def demo(img,heatmaps):
"""
:param img: (96,96)
:param heatmaps: ()
:return:
"""
# img = img.reshape(96, 96)
# axis.imshow(img, cmap='gray')
# axis.scatter(y[:, 0], y[:, 1], marker='x', s=10)
pass
def evaluate():
# 加载模型
net = KFSGNet()
net.float().cuda()
net.eval()
if (config['checkout'] != ''):
net.load_state_dict(torch.load(config['checkout']))
dataset = KFDataset(config)
dataset.load()
dataLoader = DataLoader(dataset,1)
for i,(images,_,gts) in enumerate(dataLoader):
images = Variable(images).float().cuda()
pred_heatmaps = net.forward(images)
demo_img = images[0].cpu().data.numpy()[0]
demo_img = (demo_img * 255.).astype(np.uint8)
demo_heatmaps = pred_heatmaps[0].cpu().data.numpy()[np.newaxis,...]
demo_pred_poins = get_peak_points(demo_heatmaps)[0] # (15,2)
plt.imshow(demo_img,cmap='gray')
plt.scatter(demo_pred_poins[:,0],demo_pred_poins[:,1])
plt.show()
# loss = get_mse(demo_pred_poins[np.newaxis,...],gts)
if __name__ == '__main__':
evaluate()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/key99/hourglass-facekeypoints-detection.git
git@gitee.com:key99/hourglass-facekeypoints-detection.git
key99
hourglass-facekeypoints-detection
hourglass-facekeypoints-detection
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385