解决ONNX export failure: cannot import name ‘builder‘ from ‘google.protobuf.internal‘ 问题

在进行训练完YOLOv5-lite后,想把pt文件转换成onnx文件的时候报错

报错如下:


Fusing layers... 
F:\Anaconda3\envs\yolov5\lib\site-packages\torch\functional.py:478: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered i
nternally at  C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\TensorShape.cpp:2895.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Model Summary: 167 layers, 713111 parameters, 0 gradients, 2.5 GFLOPS
  (m): ModuleList(
    (1): Conv2d(96, 21, kernel_size=(1, 1), stride=(1, 1))
  )
)
ONNX export failure: cannot import name 'builder' from 'google.protobuf.internal' (F:\Anaconda3\envs\yolov5\lib\site-packages\google\protobuf\internal\__init__.py)

查阅sackoverflew后,得到如下解决办法解决ONNX export failure: cannot import name ‘builder‘ from ‘google.protobuf.internal‘ 问题_第1张图片

 即更新protobuf至最新版即可

 pip install --upgrade protobuf 

有效嘻嘻

你可能感兴趣的:(pytorch,深度学习,python)