sdcb/PaddleSharp

Downloads for English V3 and English V4 Stalling

Closed this issue · 6 comments

Describe the bug

Whenever I run the default code found from the online docs example on my Windows 11 64 bit machine the download stalls. It hangs forever.

Steps to reproduce the bug

` private async Task<Rectangle[]> runPaddleOCR(Mat src)
{
List ocrResults = new List();
FullOcrModel model = await OnlineFullModels.EnglishV4.DownloadAsync();
using (PaddleOcrAll all = new PaddleOcrAll(model, PaddleDevice.Mkldnn())
{
AllowRotateDetection = true,
Enable180Classification = false,
})
{
PaddleOcrResult result = all.Run(src);
Console.WriteLine("Detected all texts: \n" + result.Text);
foreach (PaddleOcrResultRegion region in result.Regions)
{
var boundingRect = region.Rect.BoundingRect();
Rectangle rect = new Rectangle(boundingRect.X, boundingRect.Y, boundingRect.Width, boundingRect.Height);
ocrResults.Add(rect);
Console.WriteLine($"Text: {region.Text}, Score: {region.Score}, RectCenter: {region.Rect.Center}, RectSize: {region.Rect.Size}, Angle: {region.Rect.Angle}");
}
}

        return ocrResults.ToArray();

    }`

My code is above it always hangs on the downloadAsync line never reaching the using statement. I've tried EnglishV3 and EnglishV4.

Expected behavior

I'd like the file to download and run the model.

Screenshots

No response

Release version

No response

IDE

Visual Studio 2022 Community

OS version

Windows 11 64 bit

Additional context

No response

#104 #84 #80 #62 #32
tl;dr: Download models from upstream: https://paddlepaddle.github.io/PaddleOCR/ppocr/model_list.html and put them under the configured

public static string GlobalModelDirectory { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "paddleocr-models");

Deeplink for EnglishV(3|4) models: env4 env3
If it's still hard for you to connect these servers in China, here's mirrors on github: en_PP-OCRv4_rec_infer.tar.zip en_PP-OCRv3_det_infer.tar.zip (rename to remove .zip extension)

Hey! Thank you for getting back to me! I downloaded the models and put them in the AppData folder as instructed, however the download still stalls for some reason. Thank you for your response, but I might use Tesseract for the time being so no rush to figure it out.

Did you uncompressed that .tar?
Also feel free to modify the value of global variable GlobalModelDirectory before using it.

Yes the file is unzipped and in the correct folder. I don't mind using the GlobalModelDirectory as the folder for now. The application refuses to load the model for some reason.
image

Please remove the suffix _infer from the unextracted folder name following

public static OnlineDetectionModel EnglishV3 => new("en_PP-OCRv3_det", new Uri("https://paddleocr.bj.bcebos.com/PP-OCRv3/english/en_PP-OCRv3_det_infer.tar"), ModelVersion.V3);
public static HashSet<string> All = new(new[]
{
"arabic_PP-OCRv4_rec",
"ch_PP-OCRv4_det",
"ch_PP-OCRv4_rec",
"devanagari_PP-OCRv4_rec",
"en_PP-OCRv4_rec",
"japan_PP-OCRv4_rec",
"ka_PP-OCRv4_rec",
"korean_PP-OCRv4_rec",
"ta_PP-OCRv4_rec",
"te_PP-OCRv4_rec",
});

This worked! I got rid of the Online Model library and downloaded the Local model library. Now the local example works perfectly. Thank you!