PyMAF
PyMAF copied to clipboard
How to convert the pymaf model to onnx format.
I used the demo.py file and modified it as follows:
Then run demo.py, and the following error occurs:
/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /opt/conda/conda-bld/pytorch_1623448216815/work/c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/smplx/body_models.py:362: 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!
batch_size = max(betas.shape[0], global_orient.shape[0],
/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/smplx/body_models.py:365: 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!
if betas.shape[0] != batch_size:
/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/smplx/lbs.py:201: 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!
batch_size = max(betas.shape[0], pose.shape[0])
/home/media/xirang/pymaf/PyMAF/utils/geometry.py:67: 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!
if rotation_matrix.shape[1:] == (3,3):
/home/media/xirang/pymaf/PyMAF/utils/geometry.py:69: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
hom = torch.tensor([0, 0, 1], dtype=torch.float32,
/home/media/xirang/pymaf/PyMAF/utils/geometry.py:161: 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!
if not rotation_matrix.shape[-2:] == (3, 4):
/home/media/xirang/pymaf/PyMAF/utils/geometry.py:104: 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!
if not quaternion.shape[-1] == 4:
Traceback (most recent call last):
File "demo_onnx.py", line 603, in <module>
run_video_demo(args)
File "demo_onnx.py", line 268, in run_video_demo
torch.onnx.export(model, input_tensor, 'm20230328000537_pymaf.onnx', opset_version=12)
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/__init__.py", line 275, in export
return utils.export(model, args, f, export_params, verbose, training,
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/utils.py", line 88, in export
_export(model, args, f, export_params, verbose, training, input_names, output_names,
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/utils.py", line 689, in _export
_model_to_graph(model, args, verbose, input_names,
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/utils.py", line 463, in _model_to_graph
graph = _optimize_graph(graph, operator_export_type,
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/utils.py", line 200, in _optimize_graph
graph = torch._C._jit_pass_onnx(graph, operator_export_type)
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/__init__.py", line 313, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/utils.py", line 990, in _run_symbolic_function
symbolic_fn = _find_symbolic_in_registry(domain, op_name, opset_version, operator_export_type)
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/utils.py", line 944, in _find_symbolic_in_registry
return sym_registry.get_registered_op(op_name, domain, opset_version)
File "/home/media/miniconda3/envs/pymaf/lib/python3.8/site-packages/torch/onnx/symbolic_registry.py", line 116, in get_registered_op
raise RuntimeError(msg)
RuntimeError: Exporting the operator cross to ONNX opset version 12 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.
RuntimeError: Exporting the operator cross to ONNX opset version 12 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.
Can you give me some suggestions, thank you very much ! @HongwenZhang