hpc203 / yolact-opencv-dnn-cpp-python

使用opencv部署yolact实例分割,包含C++和Python两种版本的程序
85 stars 31 forks source link

Failed to parse onnx model in function #4

Closed Jeffin21 closed 3 years ago

Jeffin21 commented 3 years ago

self.net = cv2.dnn.readNet('yolact_base_54_800000.onnx') cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:57: error: (-210:Unsupported format or combination of formats) Failed to parse onnx model in function 'cv::dnn::dnn4_v20191202::ONNXImporter::ONNXImporter' please provide what version of opencv you tried to run

hpc203 commented 3 years ago

self.net = cv2.dnn.readNet('yolact_base_54_800000.onnx') cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:57: error: (-210:Unsupported format or combination of formats) Failed to parse onnx model in function 'cv::dnn::dnn4_v20191202::ONNXImporter::ONNXImporter' please provide what version of opencv you tried to run

你升级opencv到4.5.1或4.5.2再运行程序

Jeffin21 commented 3 years ago

@hpc203 thanks for your comment , will this program support my custom data set?

Jeffin21 commented 3 years ago

@hpc203
File "E:\yolact-opencv-dnn-cpp-python-main\main_yolact.py", line 221, in myyolact = yolact() File "E:\yolact-opencv-dnn-cpp-python-main\main_yolact.py", line 109, in init self.net = cv2.dnn.readNet('yolact_base_54_800000.onnx') cv2.error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-vi271kac\opencv\modules\dnn\src\onnx\onnx_importer.cpp:78: error: (-5:Bad argument) Can't read ONNX file: yolact_base_54_800000.onnx in function 'cv::dnn::dnn4_v20210301::ONNXImporter::ONNXImporter'

Jeffin21 commented 3 years ago

@hpc203 i run the onnx file generator code in colab i got this error

convert /content/drive/MyDrive/thirip2/yolact_base_54_800000.onnx begin
/content/thalap/yolact.py:282: TracerWarning: Converting a tensor to a Python integer 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!
  x = F.interpolate(x, size=(int(convouts[j].shape[2]), int(convouts[j].shape[3])), mode=self.interpolation_mode, align_corners=False)
/content/thalap/yolact.py:52: TracerWarning: Converting a tensor to a Python integer 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!
  return F.interpolate(x, size=(int(x.shape[2] * self.kwdargs['scale_factor']), int(x.shape[3] * self.kwdargs['scale_factor'])), mode=self.kwdargs['mode'], align_corners=self.kwdargs['align_corners'])
convert /content/drive/MyDrive/thirip2/yolact_base_54_800000.onnx to onnx finish!!!
read failed
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-11-f54ed51a524b> in <module>()
     21     try:
---> 22         dnnnet = cv2.dnn.readNet(output_onnx)
     23         print('read sucess')

error: OpenCV(4.1.2) /io/opencv/modules/dnn/src/layers/eltwise_layer.cpp:110: error: (-215:Assertion failed) inputs.size() >= 2 in function 'getMemoryShapes'

During handling of the above exception, another exception occurred:

error                                     Traceback (most recent call last)
<ipython-input-11-f54ed51a524b> in <module>()
     24     except:
     25         print('read failed')
---> 26         dnnnet = cv2.dnn.readNet(output_onnx)

error: OpenCV(4.1.2) /io/opencv/modules/dnn/src/layers/eltwise_layer.cpp:110: error: (-215:Assertion failed) inputs.size() >= 2 in function 'getMemoryShapes'
hpc203 commented 3 years ago

@hpc203 i run the onnx file generator code in colab i got this error

convert /content/drive/MyDrive/thirip2/yolact_base_54_800000.onnx begin
/content/thalap/yolact.py:282: TracerWarning: Converting a tensor to a Python integer 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!
  x = F.interpolate(x, size=(int(convouts[j].shape[2]), int(convouts[j].shape[3])), mode=self.interpolation_mode, align_corners=False)
/content/thalap/yolact.py:52: TracerWarning: Converting a tensor to a Python integer 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!
  return F.interpolate(x, size=(int(x.shape[2] * self.kwdargs['scale_factor']), int(x.shape[3] * self.kwdargs['scale_factor'])), mode=self.kwdargs['mode'], align_corners=self.kwdargs['align_corners'])
convert /content/drive/MyDrive/thirip2/yolact_base_54_800000.onnx to onnx finish!!!
read failed
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-11-f54ed51a524b> in <module>()
     21     try:
---> 22         dnnnet = cv2.dnn.readNet(output_onnx)
     23         print('read sucess')

error: OpenCV(4.1.2) /io/opencv/modules/dnn/src/layers/eltwise_layer.cpp:110: error: (-215:Assertion failed) inputs.size() >= 2 in function 'getMemoryShapes'

During handling of the above exception, another exception occurred:

error                                     Traceback (most recent call last)
<ipython-input-11-f54ed51a524b> in <module>()
     24     except:
     25         print('read failed')
---> 26         dnnnet = cv2.dnn.readNet(output_onnx)

error: OpenCV(4.1.2) /io/opencv/modules/dnn/src/layers/eltwise_layer.cpp:110: error: (-215:Assertion failed) inputs.size() >= 2 in function 'getMemoryShapes'

你是使用自己的数据集训练yolact的吗?生成onnx文件后,运行opencv程序时,检查一下输入图片resize的尺寸和类别数,是否跟训练时候的一致呢?

Jeffin21 commented 3 years ago

@hpc203 not custom data set just the yolocat pretrained files mentioned below konkona