Beispiel #1
0
 def init_det_client(self, det_port, det_client_config):
     self.det_preprocess = Sequential([
         ResizeByFactor(32, 960), Div(255),
         Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]), Transpose(
             (2, 0, 1))
     ])
     self.det_client = Client()
     self.det_client.load_client_config(det_client_config)
     self.det_client.connect(["127.0.0.1:{}".format(det_port)])
     self.ocr_reader = OCRReader()
Beispiel #2
0
 def init_det_debugger(self, det_model_config):
     self.det_preprocess = Sequential([
         ResizeByFactor(32, 960),
         Div(255),
         Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
         Transpose((2, 0, 1))
     ])
     self.det_client = Debugger()
     self.det_client.load_model_config(det_model_config,
                                       gpu=True,
                                       profile=False)
     self.ocr_reader = OCRReader()
Beispiel #3
0
 def init_rec(self):
     self.ocr_reader = OCRReader()
     self.text_recognizer = TextRecognizerHelper(global_args)
Beispiel #4
0
 def init_rec(self):
     self.ocr_reader = OCRReader()
Beispiel #5
0
 def init_op(self):
     self.ocr_reader = OCRReader()
     self.get_rotate_crop_image = GetRotateCropImage()
     self.sorted_boxes = SortedBoxes()
Beispiel #6
0
client.load_client_config(sys.argv[1:])
client.connect(["127.0.0.1:9293"])

import paddle

test_img_dir = "imgs/"


def cv2_to_base64(image):
    return base64.b64encode(image)  #data.tostring()).decode('utf8')


for img_file in os.listdir(test_img_dir):
    with open(os.path.join(test_img_dir, img_file), 'rb') as file:
        image_data = file.read()
    image = cv2_to_base64(image_data)
    fetch_map = client.predict(
        feed={"image": image},
        fetch=["ctc_greedy_decoder_0.tmp_0", "softmax_0.tmp_0"],
        batch=True)
    result = {}
    result["score"] = fetch_map["softmax_0.tmp_0"]
    del fetch_map["softmax_0.tmp_0"]
    rec_res = OCRReader().postprocess(fetch_map, with_score=False)
    res_lst = []
    for res in rec_res:
        res_lst.append(res[0])
    result["res"] = res_lst

    print(result)
 def init_rec(self):
     self.ocr_reader = OCRReader()
     self.text_classifier = TextClassifierHelper(global_args)