DAN: a Segmentation-free Document Attention Network for Handwritten Document Recognition
For more details about this package, make sure to see the documentation available at https://atr.pages.teklia.com/dan/.
This is an open-source project, licensed using the CeCILL-C license.
Inference
To apply DAN to an image, one needs to first add a few imports and to load an image. Note that the image should be in RGB.
import cv2
from dan.ocr.predict.inference import DAN
image = cv2.cvtColor(cv2.imread(IMAGE_PATH), cv2.COLOR_BGR2RGB)
Then one can initialize and load the trained model with the parameters used during training. The directory passed as parameter should have:
- a
model.ptfile, - a
charset.pklfile, - a
parameters.ymlfile corresponding to theinference_parameters.ymlfile generated during training.
from pathlib import Path
model_path = Path("models")
model = DAN("cpu")
model.load(model_path, mode="eval")
To run the inference on a GPU, one can replace cpu by the name of the GPU. In the end, one can run the prediction:
from pathlib import Path
from dan.utils import parse_charset_pattern
# Load image
image_path = Path("images/page.jpg")
image = read_image(image_path)
_, preprocessed_normalized_image = dan_model.preprocess(image)
input_tensor = preprocessed_normalized_image.unsqueeze(0)
input_tensor = input_tensor.to("cpu")
input_sizes = [preprocessed_normalized_image.shape[1:]]
original_sizes = [image.shape[1:]]
# Predict
text, confidence_scores = model.predict(
input_tensor,
input_sizes,
original_sizes,
char_separators=parse_charset_pattern(dan_model.charset),
confidences=True,
)
Training
This package provides three subcommands. To get more information about any subcommand, use the --help option.
Get started
See the dedicated page on the official DAN documentation.
Data extraction from Arkindex
See the dedicated page on the official DAN documentation.
Model training
See the dedicated page on the official DAN documentation.
Model prediction
See the dedicated page on the official DAN documentation.
Metadata
Release files for atr-dan 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| atr_dan-0.2.3.tar.gz | 105.8 kB | Without provenance | Details for atr_dan-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| atr_dan-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for atr_dan-0.2.3-py3-none-any.whl |
Total release size: 235.6 kB
Release files / atr_dan-0.2.3.tar.gz
| Download URL | atr_dan-0.2.3.tar.gz |
|---|---|
| Size | 105.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
049e151baa021aec111695416e271ebf54dffa8192b645a8e4874d4dc54e2d93
|
|
BLAKE2b-256 checksum How to use checksums |
94fc3805e10ff90c17da0d2534f75ae91fc33b007dc9c46cda9153b9d512155b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Release files / atr_dan-0.2.3-py3-none-any.whl
| Download URL | atr_dan-0.2.3-py3-none-any.whl |
|---|---|
| Size | 129.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68d285a95a4f3adc7e1d5bd5e939f9cb01b2beb5a3fa39e3b66795fdb4343c3a
|
|
BLAKE2b-256 checksum How to use checksums |
c805246a86e23723021169b87593b46b8f20d635740038ec896b97fa6461f304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.15
|
Security for atr-dan 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.