Skip to main content

VietOCR

Các bạn vui lòng cập nhật lên version mới nhất để không xảy ra lỗi.

Trong project này, mình cài đặt mô hình Transformer OCR nhận dạng chữ viết tay, chữ đánh máy cho Tiếng Việt. Kiến trúc mô hình là sự kết hợp tuyệt vời giữ mô hình CNN và Transformer (là mô hình nền tảng của BERT khá nổi tiếng). Mô hình TransformerOCR có rất nhiều ưu điểm so với kiến trúc của mô hình CRNN đã được mình cài đặt. Các bạn có thể đọc tại đây về kiến trúc và cách huấn luyện mô hình với các tập dữ liệu khác nhau.

Mô hình VietOCR có tính tổng quát cực tốt, thậm chí có độ chính xác khá cao trên một bộ dataset mới mặc dù mô hình chưa được huấn luyện bao giờ.

Cài Đặt

Để cài đặt các bạn gõ lệnh sau

pip install vietocr

Quick Start

Các bạn tham khảo notebook này để biết cách sử dụng nhé.

Cách tạo file train/test

File train/test có 2 cột, cột đầu tiên là tên file, cột thứ 2 là nhãn(không chứa kí tự \t), 2 cột này cách nhau bằng \t

20160518_0151_25432_1_tg_3_5.png để nghe phổ biến chủ trương của UBND tỉnh Phú Yên
20160421_0102_25464_2_tg_0_4.png môi trường lại đều đồng thanh

Tham khảo file mẫu tại đây

Model Zoo

Thư viện này cài đặt cả 2 kiểu seq model đó là attention seq2seq và transfomer. Seq2seq có tốc độ dự đoán rất nhanh và được dùng trong industry khá nhiều, tuy nhiên transformer lại chính xác hơn nhưng lúc dự đoán lại khá chậm. Do đó mình cung cấp cả 2 loại cho các bạn lựa chọn.

Mô hình này được huấn luyện trên tập dữ liệu gồm 10m ảnh, bao gồm nhiều loại ảnh khác nhau như ảnh tự phát sinh, chữ viết tay, các văn bản scan thực tế. Pretrain model được cung cấp sẵn.

Kết quả thử nghiệm trên tập 10m

Backbone Config Precision full sequence time
VGG19-bn - Transformer vgg_transformer 0.8800 86ms @ 1080ti
VGG19-bn - Seq2Seq vgg_seq2seq 0.8701 12ms @ 1080ti

Thời gian dự đoán của mô hình vgg-transformer quá lâu so với mô hình seq2seq, trong khi đó không có sự khác biệt rõ ràng giữ độ chính xác của 2 loại kiến trúc này.

Dataset

Mình chỉ cung cấp tập dữ liệu mẫu khoảng 1m ảnh tự phát sinh. Các bạn có thể tải về tại đây.

License

Mình phát hành thư viện này dưới các điều khoản của Apache 2.0 license.

Liên hệ

Nếu bạn có bất kì vấn đề gì, vui lòng tạo issue hoặc liên hệ mình tại pbcquoc@gmail.com

Metadata

Release files for vietocr 0.3.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vietocr 0.3.13
File Size Uploaded Provenance Actions
vietocr-0.3.13.tar.gz 29.6 kB Without provenance Details for vietocr-0.3.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vietocr 0.3.13
File Interpreter ABI Platform Actions
vietocr-0.3.13-py3-none-any.whl Python 3 none any Details for vietocr-0.3.13-py3-none-any.whl

Total release size: 64.2 kB

Release files / vietocr-0.3.13.tar.gz

Download URL vietocr-0.3.13.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8f4e326297a63aa9f209b478aa858084882996a2d9ab88af6d1158471b59736c
BLAKE2b-256 checksum
How to use checksums
ba0b9bc9ac71738696be86457a73f4a6a373b2919ee2543aa2c7d3cc666bc5b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Release files / vietocr-0.3.13-py3-none-any.whl

Download URL vietocr-0.3.13-py3-none-any.whl
Size 34.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
07b3777e5176b0d733cb056b68bd817371605f4b3514795fbf91ad4e181b8ccf
BLAKE2b-256 checksum
How to use checksums
838a84762197abf9b4c0a8ca0ebceda2c79adb5773a64578fd6d0776f93142ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Security for vietocr 0.3.13

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page