ocr-stav
This commit is contained in:
parent
335e65eaaa
commit
a54d7cac39
|
@ -112,7 +112,6 @@ async def messages_routing(msg, state):
|
||||||
text += '\n'
|
text += '\n'
|
||||||
|
|
||||||
normalized_text = normalize(text)
|
normalized_text = normalize(text)
|
||||||
logger.info(f'noramalized: {normalized_text}')
|
|
||||||
toxic_score = detector(normalized_text)
|
toxic_score = detector(normalized_text)
|
||||||
toxic_perc = math.floor(toxic_score * 100)
|
toxic_perc = math.floor(toxic_score * 100)
|
||||||
if toxic_score < 0.9 and text != text.replace(' ', ''):
|
if toxic_score < 0.9 and text != text.replace(' ', ''):
|
||||||
|
|
11
nlp/ocr.py
11
nlp/ocr.py
|
@ -11,11 +11,12 @@ def ocr_recognize(file_path):
|
||||||
|
|
||||||
# Use EasyOCR to detect text in the photo
|
# Use EasyOCR to detect text in the photo
|
||||||
results = reader.readtext(file_path)
|
results = reader.readtext(file_path)
|
||||||
result = results[-1]
|
if isinstance(results, list):
|
||||||
[_coords, ocr_text, ocr_accuracy] = result
|
result = results[-1]
|
||||||
logger.debug("OCR Result: %s", ocr_text)
|
[_coords, ocr_text, ocr_accuracy] = result
|
||||||
if ocr_accuracy.item() > 0.5:
|
logger.debug("OCR Result: %s", ocr_text)
|
||||||
sum_text += " " + ocr_text
|
if ocr_accuracy.item() > 0.5:
|
||||||
|
sum_text += " " + ocr_text
|
||||||
|
|
||||||
|
|
||||||
logger.debug(f'Recognized Text: {sum_text}')
|
logger.debug(f'Recognized Text: {sum_text}')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user