sdcb/mini-openvino-paddleocr

持续识别的时候,内存一直在增长

bzitlab opened this issue · 3 comments

using OpenCvSharp;
using Sdcb.OpenVINO.PaddleOCR.Models.Online;
using Sdcb.OpenVINO.PaddleOCR.Models;
using Sdcb.OpenVINO.PaddleOCR;
using System.Diagnostics;
using System;

FullOcrModel model = await OnlineFullModels.ChineseV4.DownloadAsync();

//using Mat src = Cv2.ImDecode(await new HttpClient().GetByteArrayAsync("https://io.starworks.cc:88/paddlesharp/ocr/samples/xdr5450.webp"), ImreadModes.Color);
var fileNames = Directory.GetFiles(@"E:\simpletest").ToList();

using (PaddleOcrAll all = new(model)
{
AllowRotateDetection = true,
Enable180Classification = true,
})
{
fileNames.ForEach(srcfile =>
{
// Load local file by following code:
using (Mat src = Cv2.ImRead(srcfile))
{
Stopwatch sw = Stopwatch.StartNew();
PaddleOcrResult result = all.Run(src);
Console.WriteLine($"elapsed={sw.ElapsedMilliseconds} ms");
Console.WriteLine("Detected all texts: \n" + result.Text);
foreach (PaddleOcrResultRegion region in result.Regions)
{
Console.WriteLine($"Text: {region.Text}, Score: {region.Score}, RectCenter: {region.Rect.Center}, RectSize: {region.Rect.Size}, Angle: {region.Rect.Angle}");
}
}
});
}
pkg_ver

sdcb commented

看到你升级到了0.3.1版本,它还是有相同的问题吗——也就是1300张照片,内存持续缓慢增长,最终增长到5GB?

昨天升级后跑了160张,看到内存涨到1.4G后就没再跑了.
刚才看到你的回复后,重新跑了1300张,发现内存到1.4G后增长就很缓慢了(但整体趋势还是上升的),识别完1300张后是1.6G. 升级后较之前内存达到5G有了极大的改善. 但是对于持续运行的场景,这个缓慢的增长还是有隐患, 等我弄5000张看看内存情况.
我附了一张内存图.
memory

sdcb commented

不知道是否和上游的openvino issue有关:https://github.com/openvinotoolkit/openvino/issues?q=is%3Aissue+memory+leak+is%3Aclosed ,请持续关注