cropping images leads to poorer results
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 22/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
调研方向
Start by running the reproduction script on the attached images.zip, comparing the detection output for the original and cropped versions of each image; the predictor is built by ocr_predictor with db_resnet34, crnn_vgg16_bn, assume_straight_pages=False and straighten_pages=True. Find where the two runs diverge (detection boxes or page straightening, not recognition alone). Done means either a documented explanation of the difference or a reproducible case with a proposed change. The thread has no comments, so expect to work without maintainer guidance.
由索引模型根据 Issue 内容生成。
描述
Bug description
In order to save memory I am cropping images from shape (1080, 1920, 3) to shape (1080, 1080, 3).
In the original image docTR is able to find all the numbers that I am looking for.
In the same but cropped image docTR does not find all numbers.
I would expect the results to be the same.
Is there a reason for the results I am getting?
Code snippet to reproduce the bug
from pathlib import Path
import cv2
from doctr.io import DocumentFile
from doctr.models import ocr_predictor
# initialize OCR predictor
predictor = ocr_predictor(
det_arch="db_resnet34",
reco_arch="crnn_vgg16_bn",
pretrained=True,
assume_straight_pages=False,
straighten_pages=True,
)
for i in range(1, 5):
print(f"\nProcessing image #{i}:")
for crop in [False, True]:
if crop:
preprocessed_image_filename = f"image_{i}__cropped.png"
else:
preprocessed_image_filename = f"image_{i}__original.png"
preprocessed_image_path = Path(__file__).parent / "images" / preprocessed_image_filename
# Load the preprocessed image
preprocessed = cv2.imread(str(preprocessed_image_path))
# Load OCR predictor with requested models
_, buf = cv2.imencode(".png", preprocessed)
doc = DocumentFile.from_images(buf.tobytes())
# Run OCR
result = predictor(doc)
# Print plain text result
output_text = ""
for page in result.pages:
for block in page.blocks:
for line in block.lines:
output_text += " ".join(w.value + " " for w in line.words)
print(f"OCR Result for {preprocessed_image_filename} (Crop: {crop}):\n{output_text}\n")
Error traceback
running the script gives the following output:
Processing image #1:
OCR Result for image_1__original.png (Crop: False):
490374 303 2 -
OCR Result for image_1__cropped.png (Crop: True):
- - - - - - - 49037 - - - - - ( - 0. 2 I à - - à - . r . - - - a à - - -
Processing image #2:
OCR Result for image_2__original.png (Crop: False):
489556 5022 - - à 1
OCR Result for image_2__cropped.png (Crop: True):
. 2 I a - - . - - - 5022 - - - - - - - - I 89556
Processing image #3:
OCR Result for image_3__original.png (Crop: False):
489556 303 S 2 A
OCR Result for image_3__cropped.png (Crop: True):
. I - ( 2 G - - - - - I - - - - - 56 1
Processing image #4:
OCR Result for image_4__original.png (Crop: False):
- 5 489556 3012 à
OCR Result for image_4__cropped.png (Crop: True):
A 489556 a à - - - - - I - I - - - - à I I
Environment
Collecting environment information...
DocTR version: v1.0.0
PyTorch version: 2.7.1+cu126 (torchvision 0.22.1+cu126)
OpenCV version: 4.11.0
OS: Ubuntu 24.04.2 LTS
Python version: 3.12.3
Is CUDA available (PyTorch): No
CUDA runtime version: Could not collect
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
- 主要语言
- Python
- 星标
- 6.4k
- 派生
- 684
- 平均合并
- 20 小时 40 分钟
- 30 天内合并 PR
- 30
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
mindee/doctr 的其他 Issue
-
ext: tests topic: ci type: enhancement
难度 3/5 半天 新手友好度 45/100
维护者通常 1 天内回复
-
Per-task YAML configuration for the reference training scripts可能已有人在做 @felixdittrich92 于 22 天前认领。 未关闭ext: references topic: documentation type: new feature
mindee/doctr#2149 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Release tracker - v1.2.0可能重新可做 @felixdittrich92 于 64 天前认领,目前没有进行中的 PR。 未关闭critical
维护者通常 1 天内回复
-
[table structure] Extend table structure dataset可能重新可做 @simont2k 于 85 天前认领,目前没有进行中的 PR。 未关闭topic: table comprehension
mindee/doctr#2119 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
type: enhancement
难度 5/5 一周以上 新手友好度 12/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
pgvector/pgvector-python#169 ·
-
ChaosEngine: backup-remote doctor row passes while consumer mode hides bot memory from git可能已有人在做 @MohabMohie 今天认领。 未关闭agentic
难度 2/5 1-3 小时 新手友好度 76/100
ShaftHQ/SHAFT_ENGINE#7263 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 87/100
huggingface/smolagents#3045 ·
维护者通常 1 天内回复