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

alphapose-yolov3-spp导出onnx #11

Open
TRQ-UP opened this issue Nov 29, 2021 · 0 comments
Open

alphapose-yolov3-spp导出onnx #11

TRQ-UP opened this issue Nov 29, 2021 · 0 comments

Comments

@TRQ-UP
Copy link

TRQ-UP commented Nov 29, 2021

您好:
看了您的转换,很厉害,如果我直接在alphapose代码中导出yolov3-spp加了convcat等操作报错,请帮忙指导一下

def load_yolo_model(args):
print('loading yolo model ...')
det_model = Darknet("yolo/cfg/yolov3-spp.cfg")
det_model.load_weights('models/yolo/yolov3-spp.weights')
det_model.net_info['height'] = args.inp_dim
det_inp_dim = int(det_model.net_info['height'])
assert det_inp_dim % 32 == 0
assert det_inp_dim > 32
det_model.cuda()
det_model.eval()
dummy_input = torch.randn(1, 3, 608, 608, device='cuda')
torch.onnx.export(det_model, dummy_input, './yolov3-spp-cat.onnx', verbose=True, opset_version=11)

报错:
Loading pose model from ./models/sppe/duc_se.pth
loading yolo model ...
/home/trq/wanda/AlphaPose_wanda/yolo/util.py:53: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
grid_len = np.arange(grid_size)
/home/trq/wanda/AlphaPose_wanda/yolo/util.py:53: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
grid_len = np.arange(grid_size)
/home/trq/wanda/AlphaPose_wanda/yolo/util.py:68: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
anchors = torch.FloatTensor(anchors)
Traceback (most recent call last):
File "/home/trq/wanda/AlphaPose_wanda/demo.py", line 191, in
Pose_model=Pose(opt)
File "/home/trq/wanda/AlphaPose_wanda/demo.py", line 61, in init
self.det_model,self.det_inp_dim=load_yolo_model(self.args)
File "/home/trq/wanda/AlphaPose_wanda/demo.py", line 48, in load_yolo_model
torch.onnx.export(det_model, dummy_input, './yolov3-spp-cat.onnx', verbose=True, opset_version=11)
File "/home/trq/anaconda3/lib/python3.6/site-packages/torch/onnx/init.py", line 230, in export
custom_opsets, enable_onnx_checker, use_external_data_format)
File "/home/trq/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 91, in export
use_external_data_format=use_external_data_format)
File "/home/trq/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 639, in _export
dynamic_axes=dynamic_axes)
File "/home/trq/anaconda3/lib/python3.6/site-packages/torch/onnx/utils.py", line 450, in _model_to_graph
_export_onnx_opset_version)
RuntimeError: Tensors must have same number of dimensions: got 2 and 1

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