cropping images leads to poorer results
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 22/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Ambito
- machine-learning
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 6.4k
- Fork
- 684
- Merge medio
- 20h 28m
- PR unite (30g)
- 28
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di mindee/doctr
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
ext: tests topic: ci type: enhancement
Difficoltà 3/5 Mezza giornata Idoneità per principianti 45/100
mindee/doctr#2171 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Per-task YAML configuration for the reference training scriptsForse già presa @felixdittrich92 l’ha presa 19 giorni fa. Apertaext: references topic: documentation type: new feature
mindee/doctr#2149 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Release tracker - v1.2.0Forse di nuovo libera @felixdittrich92 l’ha presa 61 giorni fa e non c’è nessuna pull request aperta. Apertacritical
mindee/doctr#2126 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[table structure] Extend table structure datasetForse di nuovo libera @simont2k l’ha presa 82 giorni fa e non c’è nessuna pull request aperta. Apertatopic: table comprehension
mindee/doctr#2119 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di mindee/doctr
Issue simili
-
bug Size: XS
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
oposs/repo-infra#93 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
Graphify-Labs/graphify#4546 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
521xueweihan/HelloGitHub#4025 ·