initialize with the necessary elements
(self, use_gpu=False, enable_mkldnn=False)
| 45 | ) |
| 46 | class 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, |
no test coverage detected