MCPcopy
hub / github.com/PaddlePaddle/PaddleOCR / _initialize

Method _initialize

deploy/hubserving/ocr_rec/module.py:45–66  ·  view source on GitHub ↗

initialize with the necessary elements

(self, use_gpu=False, enable_mkldnn=False)

Source from the content-addressed store, hash-verified

43)
44class OCRRec(hub.Module):
45 def _initialize(self, use_gpu=False, enable_mkldnn=False):
46 """
47 initialize with the necessary elements
48 """
49 cfg = self.merge_configs()
50
51 cfg.use_gpu = use_gpu
52 if use_gpu:
53 try:
54 _places = os.environ["CUDA_VISIBLE_DEVICES"]
55 int(_places[0])
56 print("use gpu: ", use_gpu)
57 print("CUDA_VISIBLE_DEVICES: ", _places)
58 cfg.gpu_mem = 8000
59 except:
60 raise RuntimeError(
61 "Environment Variable CUDA_VISIBLE_DEVICES is not set correctly. If you wanna use gpu, please set CUDA_VISIBLE_DEVICES via export CUDA_VISIBLE_DEVICES=cuda_device_id."
62 )
63 cfg.ir_optim = True
64 cfg.enable_mkldnn = enable_mkldnn
65
66 self.text_recognizer = TextRecognizer(cfg)
67
68 def merge_configs(
69 self,

Callers 1

module.pyFile · 0.45

Calls 2

merge_configsMethod · 0.95
TextRecognizerClass · 0.90

Tested by

no test coverage detected