mindee / doctr

docTR (Document Text Recognition) - a seamless, high-performing & accessible library for OCR-related tasks powered by Deep Learning.
https://mindee.github.io/doctr/
Apache License 2.0
3.31k stars 397 forks source link

Weights not loaded for fast_tiny #1665

Closed ved-genmo closed 2 days ago

ved-genmo commented 4 days ago

Bug description

doctr cannot find the weights for the FAST series of models, so it uses default initialization, which causes arbitrary results.

Code snippet to reproduce the bug

import time
from pathlib import Path
from doctr.models import detection_predictor
from doctr.io import DocumentFile
from PIL import Image, ImageDraw

model = detection_predictor(
    # arch="db_resnet50",
    arch="fast_tiny",
    pretrained=True,
)

image_paths = list(Path("YOUR_IMAGE_DIRECTORY_HERE").glob("*.png"))
# image_paths = [image_paths[1]]

# Open the image
for path in image_paths:
    docs = DocumentFile.from_images(path)
    t0 = time.time()
    result = model(docs)
    print(f"Detection took {time.time() - t0:.2f}s")

    with Image.open(path) as img:
        draw = ImageDraw.Draw(img)

        # Get image dimensions
        width, height = img.size

        # Draw bounding boxes
        for box in result[0]["words"]:
            xmin, ymin, xmax, ymax, score = box

            # Convert relative coordinates to absolute
            xmin, xmax = xmin * width, xmax * width
            ymin, ymax = ymin * height, ymax * height

            # Draw rectangle
            draw.rectangle([xmin, ymin, xmax, ymax], outline="red", width=2)

        # Save the image
        out_dir = path.parent.parent / "output"
        out_dir.mkdir(exist_ok=True)
        output_path = out_dir / f"{path.stem}_output.png"
        img.save(output_path)

    print(f"Image with bounding boxes saved to: {output_path}")

Error traceback

No traceback.

Environment

DocTR version: v0.8.1 TensorFlow version: 2.15.1 PyTorch version: N/A (torchvision N/A) OpenCV version: 4.5.5 OS: Debian GNU/Linux 12 (bookworm) Python version: 3.10.0 Is CUDA available (TensorFlow): No Is CUDA available (PyTorch): N/A CUDA runtime version: No CUDA GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA

Deep Learning backend

is_tf_available: True is_torch_available: False

felixdittrich92 commented 2 days ago

Hi @ved-genmo :wave:;

The fast checkpoints are only available on the main branch (v0.9.0a0) yet as mentioned with the last release notes :) So you could use the main branch or wait until we have released v0.9.0 (planned for next month)

Best regards, Felix