Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

cropping images leads to poorer results

オープン
#2,007 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python, pytorch

調査の方向性

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 の本文から書いたものです。

説明

type: bug
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")

images.zip

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時間 28分
マージ済み PR(30日)
28

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mindee/doctr のほかの issue

mindee/doctr の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。