From eec4484217d93ff6a0052da70fb6571e65b33766 Mon Sep 17 00:00:00 2001 From: AuroraWright Date: Mon, 12 Feb 2024 01:56:07 -0500 Subject: [PATCH] Add option for CPU only in EasyOCR --- owocr/ocr.py | 5 +++-- owocr_config.ini | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/owocr/ocr.py b/owocr/ocr.py index a324f22..58ff951 100644 --- a/owocr/ocr.py +++ b/owocr/ocr.py @@ -488,12 +488,13 @@ class EasyOCR: key = 'e' available = False - def __init__(self): + def __init__(self, config={'gpu': True}): if 'easyocr' not in sys.modules: logger.warning('easyocr not available, EasyOCR will not work!') else: logger.info('Loading EasyOCR model') - self.model = easyocr.Reader(['ja','en']) + logging.getLogger('easyocr.easyocr').disabled = True + self.model = easyocr.Reader(['ja','en'], gpu=config['gpu']) self.available = True logger.info('EasyOCR ready') diff --git a/owocr_config.ini b/owocr_config.ini index 2e2a6e8..b6ae588 100644 --- a/owocr_config.ini +++ b/owocr_config.ini @@ -32,4 +32,6 @@ ;endpoint = https://YOURPROJECT.cognitiveservices.azure.com/ [mangaocr] pretrained_model_name_or_path = kha-white/manga-ocr-base -force_cpu = False \ No newline at end of file +force_cpu = False +[easyocr] +gpu = True \ No newline at end of file