OCR-D / ocrd_froc

Apache License 2.0
7 stars 2 forks source link

Missing check for valid size of input images #11

Open FlorianKordon opened 7 months ago

FlorianKordon commented 7 months ago

Applying FROC to text line images that are too small (I didn't quantify the exact threshold) leads to different kinds of issues.

  1. Within the NN, the pooling operation can break due to insufficient height/width. image2
  2. ValueError during image resizing with pillow. image

While providing proper image sizes might also be a responsibility of previous processors, an initial check for valid image dimensions before further processing in FROC might make sense.

I've attached two screenshots.

kba commented 7 months ago

Thanks for the report. I only wrote the OCR-D wrapper, this bug seems to be part of the implementation in froc.py, so you probably understand the code better than I do - can you provide a PR?

bertsky commented 1 month ago

I tend to side with @FlorianKordon that this is the OCR-D wrapper's responsibility. One could add a few checks prior to https://github.com/OCR-D/ocrd_froc/blob/42f1ce0e369d22948f330148035ff02f9866b806/ocrd_froc/processor.py#L164, skipping and logging a warning if the image is unsuitable. (We do have these checks in other processors, too.)