mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
[Improve Serving] Add OCR det bbox in output buffer which is very important for application (#1214)
* Add ocr det bbox output * Add ocr det bbox output * Add ocr det bbox output * Add ocr det bbox output * Add ocr det bbox * Add ocr det bbox * Add ocr det bbox * Add ocr det bbox output
This commit is contained in:
@@ -99,9 +99,11 @@ if __name__ == "__main__":
|
||||
result = runner.Run([im, ])
|
||||
batch_texts = result['rec_texts']
|
||||
batch_scores = result['rec_scores']
|
||||
batch_bboxes = result['det_bboxes']
|
||||
for i_batch in range(len(batch_texts)):
|
||||
texts = batch_texts[i_batch]
|
||||
scores = batch_scores[i_batch]
|
||||
bboxes = batch_bboxes[i_batch]
|
||||
for i_box in range(len(texts)):
|
||||
print('text=', texts[i_box].decode('utf-8'), ' score=',
|
||||
scores[i_box])
|
||||
scores[i_box], ' bbox=', bboxes[i_box])
|
||||
|
||||
@@ -142,6 +142,7 @@ class TritonPythonModel:
|
||||
results = self.postprocessor.run([infer_outputs], im_infos)
|
||||
batch_rec_texts = []
|
||||
batch_rec_scores = []
|
||||
batch_box_list = []
|
||||
for i_batch in range(len(results)):
|
||||
|
||||
cls_labels = []
|
||||
@@ -158,6 +159,9 @@ class TritonPythonModel:
|
||||
crop_img = get_rotate_crop_image(ori_imgs[i_batch],
|
||||
box)
|
||||
image_list.append(crop_img)
|
||||
|
||||
batch_box_list.append(box_list)
|
||||
|
||||
cls_pre_tensors = self.cls_preprocessor.run(image_list)
|
||||
cls_dlpack_tensor = cls_pre_tensors[0].to_dlpack()
|
||||
cls_input_tensor = pb_utils.Tensor.from_dlpack(
|
||||
@@ -220,8 +224,10 @@ class TritonPythonModel:
|
||||
batch_rec_texts, dtype=np.object_))
|
||||
out_tensor_1 = pb_utils.Tensor(self.output_names[1],
|
||||
np.array(batch_rec_scores))
|
||||
out_tensor_2 = pb_utils.Tensor(self.output_names[2],
|
||||
np.array(batch_box_list))
|
||||
inference_response = pb_utils.InferenceResponse(
|
||||
output_tensors=[out_tensor_0, out_tensor_1])
|
||||
output_tensors=[out_tensor_0, out_tensor_1, out_tensor_2])
|
||||
responses.append(inference_response)
|
||||
return responses
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@ output [
|
||||
name: "POST_OUTPUT_1"
|
||||
data_type: TYPE_FP32
|
||||
dims: [ -1, 1 ]
|
||||
},
|
||||
{
|
||||
name: "POST_OUTPUT_2"
|
||||
data_type: TYPE_FP32
|
||||
dims: [ -1, -1, 1 ]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ output [
|
||||
name: "rec_scores"
|
||||
data_type: TYPE_FP32
|
||||
dims: [ -1, 1 ]
|
||||
},
|
||||
{
|
||||
name: "det_bboxes"
|
||||
data_type: TYPE_FP32
|
||||
dims: [ -1, -1, 1 ]
|
||||
}
|
||||
]
|
||||
ensemble_scheduling {
|
||||
@@ -73,6 +78,10 @@ ensemble_scheduling {
|
||||
key: "POST_OUTPUT_1"
|
||||
value: "rec_scores"
|
||||
}
|
||||
output_map {
|
||||
key: "POST_OUTPUT_2"
|
||||
value: "det_bboxes"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user