您好,我使用这个命令:
python3 demo/export.py --config-file configs/SOLOv2/wood_dataset/R101_3x.yaml --video-input 0.mp4 --opts MODEL.WEIGHTS tools/output/model_final.pth

回复: SOLOv2转ONNX教程
[05/05 17:31:02 detectron2]: Arguments: Namespace(confidence_threshold=0.5, config_file='configs/SOLOv2/wood_dataset/R101_3x.yaml', input=None, opts=['MODEL.WEIGHTS', 'tools/output/model_final.pth'], output=None, video_input='0.mp4', webcam=False)
[05/05 17:31:05 fvcore.common.checkpoint]: [Checkpointer] Loading from tools/output/model_final.pth ...
[05/05 17:31:06 fvcore.common.checkpoint]: [Checkpointer] Loading from tools/output/model_final.pth ...
/home/xss/Software/AdelaiDet/adet/modeling/solov2/solov2.py:152: TracerWarning: Iterating over a tensor might cause the trace to be incorrect. Passing a tensor of different shape won't change the number of iterations executed (and might lead to errors or silently give incorrect results).
images = [x["image"].to(self.device) for x in batched_inputs]
Traceback (most recent call last):
File "demo/export.py", line 153, in
torch.onnx.export(model, inp, 'solov2.onnx', output_names={
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/init.py", line 275, in export
return utils.export(model, args, f, export_params, verbose, training,
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 88, in export
_export(model, args, f, export_params, verbose, training, input_names, output_names,
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 689, in _export
_model_to_graph(model, args, verbose, input_names,
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 458, in _model_to_graph
graph, params, torch_out, module = _create_jit_graph(model, args,
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 422, in _create_jit_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args)
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 373, in _trace_and_get_graph_from_model
torch.jit._get_trace_graph(model, args, strict=False, _force_outplace=False, _return_inputs_states=True)
File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 1160, in _get_trace_graph
outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 127, in forward
graph, out = torch._C._create_graph_by_tracing(
File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 118, in wrapper
outs.append(self.inner(*trace_inputs))
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1039, in _slow_forward
result = self.forward(*input, **kwargs)
File "/home/xss/Software/AdelaiDet/adet/modeling/solov2/solov2.py", line 108, in forward
images = self.preprocess_image(batched_inputs)
File "/home/xss/Software/AdelaiDet/adet/modeling/solov2/solov2.py", line 152, in preprocess_image
images = [x["image"].to(self.device) for x in batched_inputs]
File "/home/xss/Software/AdelaiDet/adet/modeling/solov2/solov2.py", line 152, in
images = [x["image"].to(self.device) for x in batched_inputs]
IndexError: too many indices for tensor of dimension 3