使用Sagemaker训练的模型进行本地预测

问题描述

我已经使用内置算法语义分割在AWS SageMaker上训练了一个模型。名为model.tar.gz的经过训练的模型存储在S3上。因此,我想从S3下载此文件,然后使用它在我的本地PC上进行推理,而无需使用AWS SageMaker。

这是三个文件

  1. hyperparams.json:包括用于网络体系结构,数据输入和训练的参数。请参阅语义分割超参数。

  2. model_algo-1

  3. model_best.params

我的代码

import mxnet as mx
from mxnet import image
from gluoncv.data.transforms.presets.segmentation import test_transform
import gluoncv



img = image.imread('./bdd100k/validation/14df900d-c5c145cb.jpg')
img = test_transform(img,ctx)
img = img.astype('float32')


model = gluoncv.model_zoo.PSPNet(2)

# load the trained model
model.load_parameters('./model/model_best.params')

错误

AssertionError: Parameter 'head.psp.conv1.0.weight' is missing in file './model/model_best.params',which contains parameters: 'layer3.2.bn3.beta','layer3.0.conv3.weight','conv1.1.running_var',...,'layer2.2.bn3.running_mean','layer3.4.bn2.running_mean','layer4.2.bn3.beta','layer3.4.bn3.beta'. Set allow_missing=True to ignore missing parameters.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)