/
githubmirror
/
NLSOM
Обзор
Документация
Войти
/
githubmirror
/
NLSOM
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
society/ocr/agent.py
30 строк
818 B
mczhuge
update
29 май 2023, 00:41
29 май 2023, 00:41
9cd8a11
Код
Авторство
О чём код?
import easyocr def prompts(name, description): def decorator(func): func.name = name func.description = description return func return decorator class EasyOCR: def __init__(self, device="cpu"): self.ocr = easyocr.Reader(['ch_sim','en']) @prompts(name="EasyOCR", description="useful when you want to recognize the word or text in an image. " "The input to this tool should be a string, representing the image_path. ") def inference(self, filename): text = "" result = self.ocr.readtext(filename) for item in result: text += " " + item[1] return text.strip() if __name__ == "__main__": ocr_model = EasyOCR() result = ocr_model.inference('00155719.png') print(result)