-
Notifications
You must be signed in to change notification settings - Fork 26
OCR TFLITE #38
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
Comments
On-device OCR is pretty useful in my opinion. Just for more clarification, @tulasiram58827 took the model as shown in this official Keras example, was able to successfully convert it to TFLite. He also plans to try out EasyOCR to see if their pre-trained models could be converted to TFLite. This will be particularly useful since EasyOCR has multilingual support and the performance of their pre-trained models is vetted. @tulasiram58827 could you send a PR enlisting this project? Cc: @khanhlvg @margaretmz |
Created PR |
Hi everyone, While converting EasyOCR to ONNX I am facing not supported operator issues. So I decided to convert Keras OCR to TFLite and succesfully converted to TFLite. Also succesfully did inference and also benchmarked the dynamic range and float16 quantized model. I am in the process of creating small dataset required for integer quantization. Please follow this notebook for the conversion process and inference and also the benchmarks. @sayakpaul CC: @khanhlvg @margaretmz |
This is really wonderful. Keras OCR is indeed a fantastic project that allows us to run off-the-shelf OCR inference and even fine-tune OCR models. @tulasiram58827 I would suggest publishing these models on TF Hub as well. Also, here are a couple of comments on the notebook -
|
Looks good to me. So, in |
Done. |
Problems with Integer Quantizations: 1. Integer Quantization: I am successfully able to convert using Integer Quantization . But while doing inferencing I am facing issues:
2. Fully Integer Quantization: This is the error log while converting using Fully Integer Quantization technique:
You can reproduce the same with this Notebook |
Hi @khanhlvg I have been working on conversion of EasyOCR to TFLite . I have been getting this error while converting to TFLite.
I successfully converted the PyTorch Model to ONNX and ran the inference with sample data and the results are matching correctly. So I hope there are no issues in PyTorch --> ONNX conversion. Even there are no issues in converting to TensorFlow SavedModel. I am getting the error while converting the SavedModel to TFLite. FYI: Model consists of 2 layer Bi-Directional LSTM cells. I have attached all the mentioned details in this Notebook . To reproduce the above error you can use the same Notebook. |
The issue came from the fact that the SavedModel contains mutable variable, which isn't supported by TFLite Converter. I think it may come from the PyTorch -> ONNX -> TF conversion pipeline rather than from the fact that it's a LSTM and not being supported. I'm waiting for a TFLite engineer do take a further investigation. I'll keep you posted. |
Okay. Thanks, @khanhlvg for the update. |
What about this one @khanhlvg? Could you shed some light on it? |
Unfortunately they are the limitation of the current TFLite integer quantization engine. There isn't much we can do about that. |
Previously we succesfully created TFLite models for CRAFT text detector. But text detectors are generally aren't much use if it's not combined with OCR and I think there aren't much opensource tflite models are available in OCR. So I did as small research and initially converted captcha ocr to tflite which is giving almost same results as original model.
Please find this repo for the source code.
FYI : Also observed that training with tf-nightly resulted in improvement of accuracy (Compared with tensorflow-2.3 keeping all other parameters kept constant)
@sayakpaul
The text was updated successfully, but these errors were encountered: