Closed jonathanMindee closed 3 years ago
@jonathanMindee Thanks for reporting this!
Would you mind specifying a minimal version of the script you used that raised this error please?
Sure, I used the sample code in the README.md
from doctr.documents import read_pdf, read_img
from doctr.models import ocr_db_crnn
model = ocr_db_crnn(pretrained=True)
# PDF
doc = read_pdf("path/to/your/doc.pdf")
result = model([doc])
Strange, I'm not able to reproduce the error, even with the sample pdf. Could you run our diagnostic script and report back the result?
wget https://raw.githubusercontent.com/mindee/doctr/main/scripts/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
Collecting environment information...
DocTR version: 0.1.1a0 TensorFlow version: 2.4.1 OS: Ubuntu 18.04.5 LTS Python version: 3.6 Is CUDA available: No CUDA runtime version: Could not collect GPU models and configuration: GPU 0: GeForce RTX 2080 Ti Nvidia driver version: 455.45.01 cuDNN version: Probably one of the following: /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.0.5 /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.0.5
So my investigation led me to this conclusion: in very rare cases (occurring in one page of the document you used), the conversion of one segment (extracted from the segmentation from the text detection model) to a bounding box failed. The reason behind that is that the extrapolation of the segment to a polygon generated two sets of points rather than one. As this is used to be casted to a contiguous ndarray, if the two sets do not have the same number of points, it will generate an error.
I suspect that this is because the generated polygon overlaps also a small part of another segment. If so, keeping the set with the highest amount of points would solve the issue. I'll open up a PR to tackle this!
Can't execute read_pdf() function.
See the pdf file sent over slack to reproduce.
python 3.6.9