machine-learning - How can I get predictions from these pretrained models?
问题描述
I've been trying to generate human pose estimations, I came across many pretrained models (ex. Pose2Seg, deep-high-resolution-net ), however these models only include scripts for training and testing, this seems to be the norm in code written to implement models from research papers ,in deep-high-resolution-net I have tried to write a script to load the pretrained model and feed it my images, but the output I got was a bunch of tensors and I have no idea how to convert them to the .json annotations that I need.
total newbie here, sorry for my poor English in advance, ANY tips are appreciated.
I would include my script but its over 100 lines.
PS: is it polite to contact the authors and ask them if they can help?
because it seems a little distasteful.
解决方案
我没有做骨架检测研究,但你的问题似乎很普遍。
(1) 我认为其他人不应该从一开始就教你如何加载数据并从一开始就运行他们的代码。
(2) 要运行其他人的代码,只需修改他们提供的测试脚本,例如
https://github.com/leoxiaobin/deep-high-resolution-net.pytorch/blob/master/tools/test.py
他们已经帮助您加载模型
model = eval('models.'+cfg.MODEL.NAME+'.get_pose_net')(
cfg, is_train=False
)
if cfg.TEST.MODEL_FILE:
logger.info('=> loading model from {}'.format(cfg.TEST.MODEL_FILE))
model.load_state_dict(torch.load(cfg.TEST.MODEL_FILE), strict=False)
else:
model_state_file = os.path.join(
final_output_dir, 'final_state.pth'
)
logger.info('=> loading model from {}'.format(model_state_file))
model.load_state_dict(torch.load(model_state_file))
model = torch.nn.DataParallel(model, device_ids=cfg.GPUS).cuda()
打电话
# evaluate on Variable x with testing data
y = model(x)
# access Variable's tensor, copy back to CPU, convert to numpy
arr = y.data.cpu().numpy()
# write CSV
np.savetxt('output.csv', arr)
你应该可以用excel打开
(3)“将它们转换为我需要的 .json 注释”。
这是没有人可以帮助的问题。我们不知道您想要什么格式。对于他们的格式,可以通过他们的论文获得。或者查看他们的训练数据
X, y = torch.load('some_training_set_with_labels.pt')
通过关联 x 和 y。那么你应该有一个很好的主意。
推荐阅读
- javascript - 云函数 onCreate 触发函数失败 HTTP 错误:400,请求有错误
- python-3.x - 如何减少针对文本处理和电影评论训练的简单神经网络的过度拟合
- python - 想澄清 heapq.nlargest 参数'key'
- react-native - KeyboardAvoidingView 应该是视图的底部
- javascript - 如何从呈现本地 HTML 的 WebView 执行跨域请求?
- php - 如何在 PHP/Laravel 中 POST 后保留克隆的字段值
- ios - 结合超时链接
- reactjs - 开玩笑:接听电话数:0
- jquery - 我的 jquery 代码在 safari 旧版本中不支持,但在最新版本和 chrome 上也可以正常工作
- node.js - 服务器响应不需要的响应?