opendatalab / PDF-Extract-Kit

A Comprehensive Toolkit for High-Quality PDF Content Extraction
https://pdf-extract-kit.readthedocs.io/zh-cn/latest/index.html
GNU Affero General Public License v3.0
5.3k stars 361 forks source link

绘制矩形框时坐标错误 #63

Open AnnaYanami-8 opened 3 months ago

AnnaYanami-8 commented 3 months ago

Traceback (most recent call last): File "/home/dell/yangyudong/PDF-Extract-Kit/pdf_extract.py", line 229, in draw.rectangle([x_min, y_min, x_max, y_max], fill=None, outline=color_palette[label], width=1) File "/home/dell/anaconda3/envs/pipeline/lib/python3.10/site-packages/PIL/ImageDraw.py", line 413, in rectangle self.draw.draw_rectangle(xy, ink, 0, width) ValueError: y1 must be greater than or equal to y0

wufan-tb commented 3 months ago

It's odd for the y_max is usually larger than y_min. If a text is very small indeed(pixel level), the detection model may fail to detect it.

Anyway, there is a trick to handle this error, which is changing line 299 to:

draw.rectangle([x_min, y_min, x_max+1, y_max+1], fill=None, outline=color_palette[label], width=1)

Could you please send a picture of visualization pdf that contains this small bbox, we may consider fixing this situation in the next version.