MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / main

Function main

tools/infer/predict_rec.py:111–136  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

109
110
111def main(args):
112 args.use_gpu = check_gpu(args.use_gpu)
113
114 image_file_list = get_image_file_list(args.image_dir)
115 text_recognizer = TextRecognizer(args)
116 valid_image_file_list = []
117 img_list = []
118
119 # warmup 2 times
120 if args.warmup:
121 img = np.random.uniform(0, 255, [48, 320, 3]).astype(np.uint8)
122 for i in range(2):
123 text_recognizer([img] * int(args.rec_batch_num))
124
125 for image_file in image_file_list:
126 img, flag, _ = check_and_read(image_file)
127 if not flag:
128 img = cv2.imread(image_file)
129 if img is None:
130 logger.info(f'error in loading image:{image_file}')
131 continue
132 valid_image_file_list.append(image_file)
133 img_list.append(img)
134 rec_res, _ = text_recognizer(img_list)
135 for ino in range(len(img_list)):
136 logger.info(f'result of {valid_image_file_list[ino]}:{rec_res[ino]}')
137
138
139if __name__ == '__main__':

Callers 1

predict_rec.pyFile · 0.70

Calls 4

check_gpuFunction · 0.90
get_image_file_listFunction · 0.90
check_and_readFunction · 0.90
TextRecognizerClass · 0.85

Tested by

no test coverage detected