sdcb/mini-openvino-paddleocr

PaddleOCR Detection Model Fails to Load in Release Mode, but Works in Debug Mode

theonewolf opened this issue · 1 comments

@sdcb getting an odd error when I run release build and not debug build. My code is almost exactly like the example code.

I async download the models, then run on an image.

I don't understand why?

In release mode, I get this exception (in debug mode no exception):

Downloading ch_PP-OCRv4_det model from https://paddleocr.bj.bcebos.com/PP-OCRv4/chinese/ch_PP-OCRv4_det_infer.tar
Extracting C:\Users\User\AppData\Roaming\paddleocr-models\ch_PP-OCRv4_det\ch_PP-OCRv4_det_infer.tar to C:\Users\User\AppData\Roaming\paddleocr-models\ch_PP-OCRv4_det
Downloading ch_ppocr_mobile_v2.0_cls model from https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar
Extracting C:\Users\User\AppData\Roaming\paddleocr-models\ch_ppocr_mobile_v2.0_cls\ch_ppocr_mobile_v2.0_cls_infer.tar to C:\Users\User\AppData\Roaming\paddleocr-models\ch_ppocr_mobile_v2.0_cls
Downloading en_PP-OCRv4_rec model from https://paddleocr.bj.bcebos.com/PP-OCRv4/english/en_PP-OCRv4_rec_infer.tar
Extracting C:\Users\User\AppData\Roaming\paddleocr-models\en_PP-OCRv4_rec\en_PP-OCRv4_rec_infer.tar to C:\Users\User\AppData\Roaming\paddleocr-models\en_PP-OCRv4_rec

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> Sdcb.OpenVINO.OpenVINOException: general error(-1) Exception from src\inference\src\cpp\core.cpp:87:
Exception from src\inference\src\model_reader.cpp:160:
Unable to read the model: C:\Users\User\AppData\Roaming\paddleocr-models\ch_PP-OCRv4_det\inference.pdmodel Please check that model format: pdmodel is supported and the model is correct. Available frontends: ir onnx

 in file "C:\Users\ZhouJie\source\repos\OpenVINO.NET\src\Sdcb.OpenVINO\OVCore.cs" member "ReadModel" at line 213 when calling "ov_core_read_model_unicode((ov_core*)Handle, modelPathPtr, binPathPtr, &model)"
   at Sdcb.OpenVINO.OpenVINOException.ThrowIfFailed(ov_status_e e, String message, String callerMemberName, String callerExpression, String callerFilePath, Nullable`1 callerLineNumber)
   at Sdcb.OpenVINO.OVCore.ReadModel(String modelPath, String binPath)
   at Sdcb.OpenVINO.PaddleOCR.PaddleOVCoreExtensions.ReadDirectoryPaddleModel(OVCore core, String directoryPath, String modelFileName)
   at Sdcb.OpenVINO.PaddleOCR.Models.Details.FileDetectionModel.CreateOVModel(OVCore core)
   at Sdcb.OpenVINO.BaseModel.CreateCompiledModel(DeviceOptions options, Action`1 afterReadModel, Action`2 prePostProcessing, Action`1 afterBuildModel, Action`1 afterCompiledModel)
   at Sdcb.OpenVINO.PaddleOCR.PaddleOcrDetector..ctor(DetectionModel model, DeviceOptions options, Nullable`1 staticShapeSize)
   at Sdcb.OpenVINO.PaddleOCR.PaddleOcrAll..ctor(FullOcrModel model, PaddleOcrOptions options)
   at Sdcb.OpenVINO.PaddleOCR.PaddleOcrAll..ctor(FullOcrModel model, DeviceOptions device)

@sdcb I find this is happening with BenchmarkDotNet when I do not have --keepFiles active. I believe a DLL must be missing or some other misconfiguration is happening from BenchmarkDotNet, and using --keepFiles doesn't cause it.

I will track this down, and RCA. This is not a OpenVino.NET bug I do not believe.