mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-27 04:24:45 +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:
|
||||
device = decide_device(accelerator_options.device)
|
||||
# Enable easyocr GPU if running on CUDA, MPS
|
||||
use_gpu = device in [
|
||||
AcceleratorDevice.CUDA,
|
||||
AcceleratorDevice.MPS,
|
||||
]
|
||||
use_gpu = any(
|
||||
filter(
|
||||
lambda x: str(x) in device,
|
||||
[AcceleratorDevice.CUDA, AcceleratorDevice.MPS],
|
||||
)
|
||||
)
|
||||
|
||||
self.reader = easyocr.Reader(
|
||||
lang_list=self.options.lang,
|
||||
gpu=use_gpu,
|
||||
|
@ -42,7 +42,7 @@ class RapidOcrModel(BaseOcrModel):
|
||||
|
||||
# Decide the accelerator devices
|
||||
device = decide_device(accelerator_options.device)
|
||||
use_cuda = device == AcceleratorDevice.CUDA
|
||||
use_cuda = AcceleratorDevice.CUDA in device
|
||||
use_dml = accelerator_options.device == AcceleratorDevice.AUTO
|
||||
intra_op_num_threads = accelerator_options.num_threads
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user