faustomorales / keras-ocr

A packaged and flexible version of the CRAFT text detector and Keras CRNN recognition model.
https://keras-ocr.readthedocs.io/
MIT License
1.38k stars 355 forks source link

How to speed up detection's inference time ? #105

Open Duv54 opened 4 years ago

Duv54 commented 4 years ago

Hello, I am working on scanned documents of approximately 2048 * ~ 2900 pixels which contain ~ 500/600 words. The detector works better than Tesseract's segmentation. However, detection time is important for me and it takes about 8 seconds for 1 frame with Keras_ocr while it takes 0.6s for Tesseract. How could I speed up the detection part? If I resize the images to a lower width and height, the processing time decreases enormously but the performance of the detector also decreases enormously until only detecting 3 boxes out of 500 present

faustomorales commented 4 years ago

To increase detection speed, just a couple ideas:

Duv54 commented 4 years ago

Thanks for your response. I will take a look. I saw that in tensorflow v2 you have config.optimizer.set_experimental_options() that could speed up the inference time.

kbrajwani commented 3 years ago

Hey guys, in my image there is more than 500 words and detection takes average 10 seconds on colab GPU can you tell me it's normal? Also have you found any solution?

kbrajwani commented 3 years ago

Hi @faustomorales, Currently, i want to reduce time and focusing on the detection part first. I seen the original craft repo is giving a prediction in 1.3 seconds on my image and the same image keras_ocr takes 3.4 seconds. When i look changes i found by change this line reduce time to 2.9 seconds https://github.com/clovaai/CRAFT-pytorch/blob/master/craft_utils.py#L45 segmap[np.logical_and(link_score, text_score)] = 0 to segmap[np.logical_and(link_score==1, text_score==0)] = 0 can you tell me why you change this?