breezedeus / Pix2Text

An Open-Source Python3 tool with SMALL models for recognizing layouts, tables, math formulas (LaTeX), and text in images, converting them into Markdown format. A free alternative to Mathpix, empowering seamless conversion of visual content into text-based representations. 80+ languages are supported.
https://p2t.breezedeus.com
MIT License
1.98k stars 188 forks source link

列表索引超出范围 是什么原因呢? #111

Closed Metasymbols closed 4 months ago

Metasymbols commented 6 months ago

2024-05-22 20:37:12.496906: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
[WARNING 2024-05-22 20:37:15,903 _tfmw_add_deprecation_warning:149] From D:\Program Files\anaconda3\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.

Fix size testing. training chunk_sizes: [32] The output will be saved to D:\Program Files\anaconda3\lib\site-packages\pix2text\doc_xl_layout....\exp\ctdet_subfield\default heads {'hm': 11, 'cls': 4, 'ftype': 3, 'wh': 8, 'hm_sub': 2, 'wh_sub': 8, 'reg': 2, 'reg_sub': 2} [WARNING 2024-05-22 20:37:20,113 check_img_size:147] --img-size 699 must be multiple of max stride 32, updating to 704 [WARNING 2024-05-22 20:37:20,221 _showwarnmsg:109] D:\Program Files\anaconda3\lib\site-packages\torch\functional.py:507: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ..\aten\src\ATen\native\TensorShape.cpp:3550.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]

0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:20,426 check_img_size:147] --img-size 186 must be multiple of max stride 32, updating to 192 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:20,523 check_img_size:147] --img-size 149 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:20,635 check_img_size:147] --img-size 138 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:21,647 check_img_size:147] --img-size 1086 must be multiple of max stride 32, updating to 1088 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:23,684 check_img_size:147] --img-size 78 must be multiple of max stride 32, updating to 96 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:23,852 check_img_size:147] --img-size 159 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:23,950 check_img_size:147] --img-size 112 must be multiple of max stride 32, updating to 128 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,046 check_img_size:147] --img-size 113 must be multiple of max stride 32, updating to 128 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,140 check_img_size:147] --img-size 103 must be multiple of max stride 32, updating to 128 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,216 check_img_size:147] --img-size 154 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,315 check_img_size:147] --img-size 98 must be multiple of max stride 32, updating to 128 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,407 check_img_size:147] --img-size 99 must be multiple of max stride 32, updating to 128 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,513 check_img_size:147] --img-size 166 must be multiple of max stride 32, updating to 192 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,617 check_img_size:147] --img-size 152 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,712 check_img_size:147] --img-size 173 must be multiple of max stride 32, updating to 192 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:24,800 check_img_size:147] --img-size 217 must be multiple of max stride 32, updating to 224 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 5.65it/s] [WARNING 2024-05-22 20:37:25,087 check_img_size:147] --img-size 132 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:25,179 check_img_size:147] --img-size 152 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:25,272 check_img_size:147] --img-size 177 must be multiple of max stride 32, updating to 192 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:25,363 check_img_size:147] --img-size 177 must be multiple of max stride 32, updating to 192 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:25,450 check_img_size:147] --img-size 134 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:25,533 check_img_size:147] --img-size 146 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:25,621 check_img_size:147] --img-size 142 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:25,701 check_img_size:147] --img-size 154 must be multiple of max stride 32, updating to 160 0it [00:00, ?it/s] [WARNING 2024-05-22 20:37:26,707 check_img_size:147] --img-size 1086 must be multiple of max stride 32, updating to 1088 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8 [00:34<00:00, 4.28s/it] Traceback (most recent call last): File "g:\Workspace\code\py_code\text\pdf2md.py", line 24, in doc = p2t.recognize_pdf(img_fp) File "D:\Program Files\anaconda3\lib\site-packages\pix2text\pix_to_text.py", line 191, in recognize_pdf self.recognize_page( File "D:\Program Files\anaconda3\lib\site-packages\pix2text\pix_to_text.py", line 358, in recognize_page remaining_blocks = self._parse_remaining( File "D:\Program Files\anaconda3\lib\site-packages\pix2text\pix_to_text.py", line 410, in _parse_remaining match_col_number = overlap_vals[0][0] IndexError: list index out of range

breezedeus commented 6 months ago

这个 bug 在 v1.1.0.4 中应该已经修复了,可以更新下 pix2text 版本

lvzhaokun commented 6 months ago

这个错误在 v1.1.0.4 中应该已经修复了,可以更新下一个 pix2text 版本

我就是用的这个版本,并没有修复呢

breezedeus commented 6 months ago

😅 能贴下你的文件/图片吗?我试试复现下。

Metasymbols commented 4 months ago

😅能贴下你的文件/图片吗?我试试复现一下。

我对pix_to_text.py文件第410行代码添加判断条件,暂时修复了!

for _box_info in _out:
            overlap_vals = []
            for col_number, col_info in column_meta.items():
                overlap_val = x_overlap(_box_info, col_info, key='position')
                overlap_vals.append([col_number, overlap_val])
            if len(overlap_vals) > 0:
                overlap_vals.sort(key=lambda x: (x[1], x[0]), reverse=True)
                match_col_number = overlap_vals[0][0]
            else:
                match_col_number = 0
            _box_info['col_number'] = match_col_number

就是overlap_vals不能为空值

lvzhaokun commented 4 months ago

😅能贴下你的文件/图片吗?我试试复现一下。

我对pix_to_text.py文件第410行代码添加判断条件,暂时修复了!

for _box_info in _out:
            overlap_vals = []
            for col_number, col_info in column_meta.items():
                overlap_val = x_overlap(_box_info, col_info, key='position')
                overlap_vals.append([col_number, overlap_val])
            if len(overlap_vals) > 0:
                overlap_vals.sort(key=lambda x: (x[1], x[0]), reverse=True)
                match_col_number = overlap_vals[0][0]
            else:
                match_col_number = 0
            _box_info['col_number'] = match_col_number

就是overlap_vals不能为空值

恩恩。好的 感谢大佬