normalized-log-fix8
This commit is contained in:
parent
5d16c895ac
commit
9fc576bd61
|
@ -1,7 +1,7 @@
|
||||||
import easyocr
|
import easyocr
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logger = logging.getLogger("[ocr] ")
|
logger = logging.getLogger(" ocr ")
|
||||||
|
|
||||||
# Initialize the EasyOCR reader
|
# Initialize the EasyOCR reader
|
||||||
reader = easyocr.Reader(['ru']) # Specify the languages you want to support
|
reader = easyocr.Reader(['ru']) # Specify the languages you want to support
|
||||||
|
@ -9,8 +9,10 @@ reader = easyocr.Reader(['ru']) # Specify the languages you want to support
|
||||||
def ocr_recognize(file_path):
|
def ocr_recognize(file_path):
|
||||||
# Use EasyOCR to detect text in the photo
|
# Use EasyOCR to detect text in the photo
|
||||||
result = reader.readtext(file_path)
|
result = reader.readtext(file_path)
|
||||||
|
logger.debug(result)
|
||||||
|
|
||||||
# Extract the recognized text from the result
|
# Extract the recognized text from the result
|
||||||
recognized_text = ' '.join([text[0] for text, _, _ in result if isinstance(text, list) and text])
|
recognized_text = ' '.join([text[0] for text in result if isinstance(text, tuple) and len(text) > 0])
|
||||||
|
|
||||||
logger.debug(f'recognized_text: {recognized_text}')
|
logger.debug(f'recognized_text: {recognized_text}')
|
||||||
return recognized_text
|
return recognized_text
|
Loading…
Reference in New Issue
Block a user