Get the chinese texts in the predicted images. Args: images (list(numpy.ndarray)): images data, shape of each is [H, W, C]. If images not paths paths (list[str]): The paths of images. If paths not images Returns: res (list): The result of
(self, images=[], paths=[])
| 96 | return images |
| 97 | |
| 98 | def predict(self, images=[], paths=[]): |
| 99 | """ |
| 100 | Get the chinese texts in the predicted images. |
| 101 | Args: |
| 102 | images (list(numpy.ndarray)): images data, shape of each is [H, W, C]. If images not paths |
| 103 | paths (list[str]): The paths of images. If paths not images |
| 104 | Returns: |
| 105 | res (list): The result of chinese texts and save path of images. |
| 106 | """ |
| 107 | |
| 108 | if images != [] and isinstance(images, list) and paths == []: |
| 109 | predicted_data = images |
| 110 | elif images == [] and isinstance(paths, list) and paths != []: |
| 111 | predicted_data = self.read_images(paths) |
| 112 | else: |
| 113 | raise TypeError("The input data is inconsistent with expectations.") |
| 114 | |
| 115 | assert ( |
| 116 | predicted_data != [] |
| 117 | ), "There is not any image to be predicted. Please check the input data." |
| 118 | |
| 119 | all_results = [] |
| 120 | for img in predicted_data: |
| 121 | if img is None: |
| 122 | logger.info("error in loading image") |
| 123 | all_results.append([]) |
| 124 | continue |
| 125 | starttime = time.time() |
| 126 | res, _ = self.table_sys(img) |
| 127 | elapse = time.time() - starttime |
| 128 | logger.info("Predict time: {}".format(elapse)) |
| 129 | |
| 130 | all_results.append({"html": res["html"]}) |
| 131 | return all_results |
| 132 | |
| 133 | @serving |
| 134 | def serving_method(self, images, **kwargs): |
no test coverage detected