Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model very sensitive on PNG input #336

Open
junyizhao04 opened this issue Mar 6, 2023 · 4 comments
Open

Model very sensitive on PNG input #336

junyizhao04 opened this issue Mar 6, 2023 · 4 comments
Labels
accuracy Concerns quality of (some model's) predictions

Comments

@junyizhao04
Copy link

I tried multiple size and source (photo from screen, paper, screenshot etc) and attempted to run it in Calamari OCR using the given model. However, the model is very sensitive towards input and only around 5% works. What is the expected PNG input size?

@andbue
Copy link
Member

andbue commented Mar 6, 2023

I don't think the input size matters that much. Please note that calamari is line based, it does not include code or models for segmentation tasks. As long as your images is cropped nicely around a single line or you provide coordinates via PAGE XML, it should work.

@junyizhao04
Copy link
Author

I don't think the input size matters that much. Please note that calamari is line based, it does not include code or models for segmentation tasks. As long as your images is cropped nicely around a single line or you provide coordinates via PAGE XML, it should work.

then I believe image like this may work, but it does not.

11

@andbue
Copy link
Member

andbue commented Mar 6, 2023

The uw3 dataset the model uw3-modern-english was trained on contains only binarised data, therefore the model struggles with colour or grayscale images. If you convert your image to monochrome, e.g. via convert online.png -monochrome online.bin.png, it's recognised perfectly.

@bertsky
Copy link
Collaborator

bertsky commented Oct 2, 2024

You can see what a model expects by lookin at its data.input_channels and data.pre_proc.processors parameters (in the JSON file), or predictor.data.params.input_channels and predictor.data.params.pre_proc.processors (at runtime). If there is just 1 channel and the first processor is a CenterNormalizerProcessor, then this model expects binarization.

Besides the simple method mentioned by @andbue there are very sophisticated algorithms and models for binarization in OCR.

I have not seen public models for Calamari trained on grayscale or colour yet.

Can we close @junyizhao04?

@bertsky bertsky added the accuracy Concerns quality of (some model's) predictions label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accuracy Concerns quality of (some model's) predictions
Projects
None yet
Development

No branches or pull requests

3 participants