hezarai / hezar

The all-in-one AI library for Persian, supporting a wide variety of tasks and modalities!
https://hezarai.github.io/hezar/
Apache License 2.0
843 stars 45 forks source link

Confidence level for license plate OCR #138

Closed claymore07 closed 9 months ago

claymore07 commented 9 months ago

Hi, First of all, Thank you for your great work. I'm using "crnn-fa-64x256-license-plate-recognition" for license plate OCR, It works really well, however, I need a confidence level for read text, like EasyOCR. Is there a way to get this value alongside the license plate text? Best Regards

arxyzan commented 9 months ago

Hello @claymore07, thanks for your feedback! I just added support for this in b5e5d524776f06cf43472d9d75bb5feb00b791ed .

Demo:

from hezar.models import Model

model = Model.load("hezarai/crnn-fa-64x256-license-plate-recognition")  # CRNN
text = model.predict("../assets/license_plate_ocr_example.jpg", return_scores=True)
print(text)

The output now includes a score field for each sample in the batch that represents the mean confidence over all characters:

[{'text': '۷۷۹۷۷س۷۵', 'score': 0.9834718108177185}]

This feature be included in the next release of Hezar but if you want to try it urgently, you can install Hezar from source (main branch):

git clone https://github.com/hezarai/hezar.git
cd hezar
pip install ".[vision]"
claymore07 commented 9 months ago

Thanks a lot for your comprehensive response