Skip to content

Commit 66c8509

Browse files
authored
Merge pull request #7 from Bourn3z/dev-offlineinfer
Add the function of concatenating to crops after detection.
2 parents 66850a4 + 4626519 commit 66c8509

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

deploy/py_infer/src/parallel/module/detection/det_post_node.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ def concat_crops(self, crops: list):
2828
Returns:
2929
numpy.ndarray: A horizontally concatenated image array.
3030
"""
31-
crops_sorted = sorted(crops, key=lambda points: (points[0][1], points[0][0]))
32-
max_height = max(crop.shape[0] for crop in crops_sorted)
31+
max_height = max(crop.shape[0] for crop in crops)
3332
resized_crops = []
34-
for crop in crops_sorted:
33+
for crop in crops:
3534
h, w, c = crop.shape
3635
new_h = max_height
3736
new_w = int((w / h) * new_h)
@@ -48,6 +47,8 @@ def process(self, input_data):
4847

4948
data = input_data.data
5049
boxes = self.text_detector.postprocess(data["pred"], data["shape_list"])
50+
if self.is_concat:
51+
boxes = sorted(boxes, key=lambda points: (points[0][1], points[0][0]))
5152

5253
infer_res_list = []
5354
for box in boxes:

deploy/py_infer/src/parallel/module/recognition/rec_post_node.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def __init__(self, args, msg_queue):
77
super(RecPostNode, self).__init__(args, msg_queue)
88
self.text_recognizer = None
99
self.task_type = self.args.task_type
10+
self.is_concat = self.args.is_concat
1011

1112
def init_self_args(self):
1213
self.text_recognizer = TextRecognizer(self.args)
@@ -28,9 +29,13 @@ def process(self, input_data):
2829
else:
2930
texts = output["texts"]
3031
confs = output["confs"]
31-
for result, text, conf in zip(input_data.infer_result, texts, confs):
32-
result.append(text)
33-
result.append(conf)
32+
for i, result in enumerate(input_data.infer_result):
33+
if self.is_concat:
34+
result.append(texts[0])
35+
result.append(confs[0])
36+
else:
37+
result.append(texts[i])
38+
result.append(confs[i])
3439

3540
input_data.data = None
3641

0 commit comments

Comments
 (0)