normalized-log-fix10
This commit is contained in:
parent
494cc5766f
commit
d9e9c547ef
17
nlp/ocr.py
17
nlp/ocr.py
|
@ -7,12 +7,15 @@ logger = logging.getLogger(" ocr ")
|
||||||
reader = easyocr.Reader(['ru']) # Specify the languages you want to support
|
reader = easyocr.Reader(['ru']) # Specify the languages you want to support
|
||||||
|
|
||||||
def ocr_recognize(file_path):
|
def ocr_recognize(file_path):
|
||||||
|
sum_text = ""
|
||||||
|
|
||||||
# Use EasyOCR to detect text in the photo
|
# Use EasyOCR to detect text in the photo
|
||||||
result = reader.readtext(file_path)
|
results = reader.readtext(file_path)
|
||||||
logger.debug("OCR Result: %s", result)
|
for result in results:
|
||||||
|
[_coords, ocr_text, ocr_accuracy] = result
|
||||||
|
logger.debug("OCR Result: %s", ocr_text)
|
||||||
|
if ocr_accuracy.item() > 0.5:
|
||||||
|
sum_text += ocr_text
|
||||||
|
|
||||||
# Extract recognized text
|
logger.debug(f'Recognized Text: {sum_text}')
|
||||||
recognized_text = ' '.join([text[1] for text in result if isinstance(text, tuple) and len(text) > 1])
|
return sum_text
|
||||||
|
|
||||||
logger.debug(f'Recognized Text: {recognized_text}')
|
|
||||||
return recognized_text
|
|
Loading…
Reference in New Issue
Block a user