Skip to content

Commit c3ebe9d

Browse files
authored
fix bug (#2450)
1 parent 3e61261 commit c3ebe9d

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

paddlex/inference/pipelines/ppchatocrv3/ppchatocrv3.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,14 @@ def get_visual_result(
236236
recovery=True,
237237
):
238238
# get oricls and unwarp results
239-
img_info_list = list(self.img_reader(inputs))[0]
239+
if isinstance(inputs, str):
240+
img_info_list = list(self.img_reader(inputs))[0]
241+
elif isinstance(inputs, list):
242+
assert not any(
243+
s.endswith(".pdf") for s in inputs
244+
), "List containing pdf is not supported; only a list of images or a single PDF is supported."
245+
img_info_list = [x[0] for x in list(self.img_reader(inputs))]
246+
240247
oricls_results = []
241248
if self.doc_image_ori_cls_predictor and use_doc_image_ori_cls_model:
242249
oricls_results = get_oriclas_results(
@@ -576,7 +583,7 @@ def chat(
576583
user_task_description,
577584
)
578585
logging.debug(prompt)
579-
prompt_res["ocr_prompt"] = prompt
586+
prompt_res["ocr_prompt"] = [prompt]
580587
res = self.get_llm_result(llm_api, prompt)
581588
if res:
582589
final_results.update(res)

paddlex/inference/results/chat_ocr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ class VisualResult(BaseResult):
3636
def __init__(self, data, page_id=None, src_input_name=None):
3737
super().__init__(data)
3838
self.page_id = page_id
39-
self.src_input_name = src_input_name
39+
if isinstance(src_input_name, list):
40+
self.src_input_name = src_input_name[page_id]
41+
else:
42+
self.src_input_name = src_input_name
4043

4144
def _to_str(self, _, *args, **kwargs):
4245
return super()._to_str(

paddlex/modules/multilabel_classification/dataset_checker/dataset_src/utils/visualizer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def draw_multi_label(image, label, label_map_dict):
144144
draw = ImageDraw.Draw(new_image)
145145
font_color = tuple(font_colormap(3))
146146
for i, text in enumerate(text_lines):
147-
text_width, _ = font.getsize(text)
148147
draw.text(
149148
(0, image_height + i * int(row_height * 1.2)),
150149
text,

0 commit comments

Comments
 (0)