(self, test_data)
| 50 | self.numeric_acceptance_error = numeric_acceptance_error |
| 51 | |
| 52 | def set_data(self, test_data): |
| 53 | |
| 54 | self.inputs = Attributes() |
| 55 | |
| 56 | with lzma.open(test_data, 'rb') as fid: |
| 57 | solution_book = pickle.load(fid) |
| 58 | self.test_book = solution_book['tests'] |
| 59 | |
| 60 | if any([file not in os.listdir(self.image_data_dir) for file in solution_book['inputs']['images'].keys()]): |
| 61 | raise FileNotFoundError("Cannot find {} in {}.").format(', '.join([file for file in solution_book['inputs']['images'].keys() |
| 62 | if file not in os.listdir(self.image_data_dir)], self.image_data_dir)) |
| 63 | images = {os.path.splitext(file)[0]: { |
| 64 | key: np.asarray(PIL.Image.open(os.path.join(self.image_data_dir, file)).crop(crop_box))[:,:,::-1] for (key,crop_box) in page.items() |
| 65 | } for (file,page) in solution_book['inputs']['images'].items()} |
| 66 | |
| 67 | english_mini_bgr, english_mini_gray = self.easyocr.utils.reformat_input(images['english']['mini']) |
| 68 | english_small_bgr, english_small_gray = self.easyocr.utils.reformat_input(images['english']['small']) |
| 69 | images['english'].update({'mini_bgr': english_mini_bgr, |
| 70 | 'mini_gray': english_mini_gray, |
| 71 | 'small_bgr': english_small_bgr, |
| 72 | 'small_gray': english_small_gray, |
| 73 | }) |
| 74 | |
| 75 | setattr(self.inputs, 'images', self.dict2attr(images)) |
| 76 | setattr(self.inputs, 'easyocr_config', self.dict2attr(solution_book['inputs']['easyocr_config'])) |
| 77 | |
| 78 | def dict2attr(self, dict_): |
| 79 | attr = Attributes() |
no test coverage detected