raoyutian / PaddleOCRSharp

PaddleOCRSarp是一个基于百度飞桨PaddleOCR的C++代码修改并封装的.NET的OCR工具类库。包含文本识别、文本检测、表格识别功能。本项目针对小图识别不准的情况下做了优化,比飞桨原代码识别准确率有所提高。 包含总模型仅8.6M的超轻量级中文OCR,单模型支持中英文数字组合识别、竖排文本识别、长文本识别。同时支持多种文本检测。
Apache License 2.0
606 stars 99 forks source link

循环调用DetectText报错 #41

Closed igaobingbing closed 4 months ago

igaobingbing commented 4 months ago

1、包版本

<PackageReference Include="PaddleOCRSharp" Version="4.2.0" />

2、PaddleOCREngine全局初始化 3、调用代码

 foreach (var file in Request.Form.Files)
 {
     var bytes = new byte[file.Length];
     using (var fileStream = file.OpenReadStream())
     {
         fileStream.Read(bytes, 0, (int)file.Length);
     }
     var text = ocr.DetectText(bytes);
     result.Add(new { key = file.FileName, value = text });
 }
错误:
1、JsonSerializationException: Error converting value {null} to type 'System.Single'. Path '[0].cls_score', line 1, position 131.
2、InvalidCastException: Null object cannot be converted to a value type.
raoyutian commented 4 months ago

下个版本修复。 可能是升级Json序列化库导致。之前的版本一直没有这个问题。

igaobingbing commented 4 months ago

好吧,哪个版本没有问题呢 ---- 回复的原邮件 ---- 发件人Yutian @.>发送日期2024年04月20日 16:21 @.> @.>, @.>主题Re: [raoyutian/PaddleOCRSharp] 循环调用DetectText报错 (Issue #41) 下个版本修复。 可能是升级Json序列化库导致。之前的版本一直没有这个问题。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

raoyutian commented 4 months ago

好吧,哪个版本没有问题呢 ---- 回复的原邮件 ---- 发件人Yutian @.>发送日期2024年04月20日 16:21 @.> @.>, @.>主题Re: [raoyutian/PaddleOCRSharp] 循环调用DetectText报错 (Issue #41) 下个版本修复。 可能是升级Json序列化库导致。之前的版本一直没有这个问题。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

你可以试试4.1版本

igaobingbing commented 4 months ago

4.1版本也是如此

raoyutian commented 4 months ago

4.1版本也是如此

那就不你知道你的问题所在了,我自己以及别人的服务都好好的。

igaobingbing commented 4 months ago

我部署为 win 服务,然后多个客户端调用接口(存在并发),服务内部仅仅实例化一次引擎,难道我的用法不对 ---- 回复的原邮件 ---- 发件人Yutian @.>发送日期2024年04月25日 14:36 @.> @.>, @.>主题Re: [raoyutian/PaddleOCRSharp] 循环调用DetectText报错 (Issue #41) 4.1版本也是如此 那就不你知道你的问题所在了,我自己以及别人的服务都好好的。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

raoyutian commented 4 months ago

我部署为 win 服务,然后多个客户端调用接口(存在并发),服务内部仅仅实例化一次引擎,难道我的用法不对 ---- 回复的原邮件 ---- 发件人Yutian @.>发送日期2024年04月25日 14:36 @.> @.>, @.>主题Re: [raoyutian/PaddleOCRSharp] 循环调用DetectText报错 (Issue #41) 4.1版本也是如此 那就不你知道你的问题所在了,我自己以及别人的服务都好好的。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

并发服务,实例创建加锁,确保一个进程只创建一个实例