|
环境为rknn1.6,自己的模型使用pytorch1.7训练得到的,首先把模型转为有网络结构的模型具体代码如下:
model = YoloBody(3,26 ,backbone=backbone ,pretrained=pretrained)
model_path = r"../logs/Epoch100-Total_Loss5.9059-Val_Loss5.0253.pth"
print('Loading weights into state dict...')
device = torch.device('cpu')
state_dict = torch.load(model_path, map_location=device)
model.load_state_dict(state_dict)
model.eval()
# 向模型中输入数据以得到模型参数
example = torch.Tensor(1,3,416,416)
trace_model = torch.jit.trace(model, example)
trace_model.save('./final.pt')
然后使用官方的例子将模型转为rknn模型:
--> Loading model
./final.pt ********************
加载失败
E Catch exception when loading pytorch model: ./final.pt!
E Traceback (most recent call last):
E File "rknn\api\rknn_base.py", line 339, in rknn.api.rknn_base.RKNNBase.load_pytorch
E File "rknn\base\RKNNlib\RK_nn.py", line 146, in rknn.base.RKNNlib.RK_nn.RKnn.load_pytorch
E File "rknn\base\RKNNlib\app\importer\import_pytorch.py", line 128, in rknn.base.RKNNlib.app.importer.import_pytorch.ImportPytorch.run
E File "rknn\base\RKNNlib\converter\convert_pytorch_new.py", line 2250, in rknn.base.RKNNlib.converter.convert_pytorch_new.convert_pytorch.load
E File "rknn\base\RKNNlib\converter\convert_pytorch_new.py", line 2055, in rknn.base.RKNNlib.converter.convert_pytorch_new.PyTorchOpConverter.report_missing_conversion
E NotImplementedError: The following operators are not implemented: ['aten::detach', 'aten::to', 'aten::floor']
Process finished with exit code 0
请问怎样解决?(环境应该没问题,官方给的resnet50我转成功了)
|
|