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

Method _initialize

deploy/hubserving/ocr_det/module.py:47–68  ·  view source on GitHub ↗

initialize with the necessary elements

(self, use_gpu=False, enable_mkldnn=False)

Source from the content-addressed store, hash-verified

45)
46class OCRDet(hub.Module):
47 def _initialize(self, use_gpu=False, enable_mkldnn=False):
48 """
49 initialize with the necessary elements
50 """
51 cfg = self.merge_configs()
52
53 cfg.use_gpu = use_gpu
54 if use_gpu:
55 try:
56 _places = os.environ["CUDA_VISIBLE_DEVICES"]
57 int(_places[0])
58 print("use gpu: ", use_gpu)
59 print("CUDA_VISIBLE_DEVICES: ", _places)
60 cfg.gpu_mem = 8000
61 except:
62 raise RuntimeError(
63 "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."
64 )
65 cfg.ir_optim = True
66 cfg.enable_mkldnn = enable_mkldnn
67
68 self.text_detector = TextDetector(cfg)
69
70 def merge_configs(
71 self,

Callers 1

module.pyFile · 0.45

Calls 2

merge_configsMethod · 0.95
TextDetectorClass · 0.90

Tested by

no test coverage detected