mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-29 13:34:21 +00:00
fix: Do proper check to set the device in EasyOCR, RapidOCR.
Signed-off-by: Nikos Livathinos <nli@zurich.ibm.com> Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
This commit is contained in:
parent
ce82e23b66
commit
99ccb69a47
@ -45,10 +45,13 @@ class EasyOcrModel(BaseOcrModel):
|
|||||||
if self.options.use_gpu:
|
if self.options.use_gpu:
|
||||||
device = decide_device(accelerator_options.device)
|
device = decide_device(accelerator_options.device)
|
||||||
# Enable easyocr GPU if running on CUDA, MPS
|
# Enable easyocr GPU if running on CUDA, MPS
|
||||||
use_gpu = device in [
|
use_gpu = any(
|
||||||
AcceleratorDevice.CUDA,
|
filter(
|
||||||
AcceleratorDevice.MPS,
|
lambda x: str(x) in device,
|
||||||
]
|
[AcceleratorDevice.CUDA, AcceleratorDevice.MPS],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.reader = easyocr.Reader(
|
self.reader = easyocr.Reader(
|
||||||
lang_list=self.options.lang,
|
lang_list=self.options.lang,
|
||||||
gpu=use_gpu,
|
gpu=use_gpu,
|
||||||
|
@ -42,7 +42,7 @@ class RapidOcrModel(BaseOcrModel):
|
|||||||
|
|
||||||
# Decide the accelerator devices
|
# Decide the accelerator devices
|
||||||
device = decide_device(accelerator_options.device)
|
device = decide_device(accelerator_options.device)
|
||||||
use_cuda = device == AcceleratorDevice.CUDA
|
use_cuda = AcceleratorDevice.CUDA in device
|
||||||
use_dml = accelerator_options.device == AcceleratorDevice.AUTO
|
use_dml = accelerator_options.device == AcceleratorDevice.AUTO
|
||||||
intra_op_num_threads = accelerator_options.num_threads
|
intra_op_num_threads = accelerator_options.num_threads
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user