dtrocr

A PyTorch implementation of DTrOCR: Decoder-only Transformer for Optical Character Recognition

https://github.com/arvindrajan92/dtrocr

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.8%) to scientific vocabulary

Keywords

decoder dtrocr ocr pytorch recognition text-recognition transformer
Last synced: 6 months ago · JSON representation ·

Repository

A PyTorch implementation of DTrOCR: Decoder-only Transformer for Optical Character Recognition

Basic Info
  • Host: GitHub
  • Owner: arvindrajan92
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 791 KB
Statistics
  • Stars: 167
  • Watchers: 9
  • Forks: 20
  • Open Issues: 2
  • Releases: 0
Topics
decoder dtrocr ocr pytorch recognition text-recognition transformer
Created over 1 year ago · Last pushed 9 months ago
Metadata Files
Readme Funding License Citation

README.md

DTrOCR

logo Python application CodeQL Python Versions License GitHub stars

A PyTorch implementation of DTrOCR: Decoder-only Transformer for Optical Character Recognition.

[!NOTE]

The authors of this repository are not affiliated with the author of the DTrOCR paper. This implementation is independently developed, relying solely on the publicly available descriptions of the DTrOCR model architecture and its training methodologies, with a specific focus on printed and handwritten words.

Due to the project's inception as a personal endeavor with limited resources, the pre-trained weights for the model are not presently accessible. However, there is an ongoing commitment to pre-train the model and subsequently release the weights to the public. For detailed insights into the project's development and future milestones, please refer to the project roadmap.

The table below outlines the principal distinctions between the implementation described in the original paper and the current implementation.

| | Original implementation | Current implementation | |-------------------------------------------------------------| ---------------------------- |------------------------| | Maximum token length
(including 128 image patch tokens)| 512 | 256 | | Supported language(s) | English & Chinese | English | | Pre-training corpus (planned) | Scene, printed & handwritten | Printed & handwritten |

Installation

shell git clone https://github.com/arvindrajan92/DTrOCR cd DTrOCR pip install -r requirements.txt

Usage

```python from dtrocr.config import DTrOCRConfig from dtrocr.model import DTrOCRLMHeadModel from dtrocr.processor import DTrOCRProcessor

from PIL import Image

config = DTrOCRConfig() model = DTrOCRLMHeadModel(config) processor = DTrOCRProcessor(DTrOCRConfig())

model.eval() # set model to evaluation mode for deterministic behaviour pathtoimage = "" # path to image file

inputs = processor( images=Image.open(pathtoimage).convert('RGB'), texts=processor.tokeniser.bostoken, returntensors="pt" )

modeloutput = model.generate( inputs=inputs, processor=processor, numbeams=3, # defaults to 1 if not specified use_cache=True # defaults to True if not specified )

predictedtext = processor.tokeniser.decode(modeloutput[0], skipspecialtokens=True) ```

Acknowledgments

This project builds upon the original work presented in DTrOCR: Decoder-only Transformer for Optical Character Recognition, authored by Masato Fujitake. We extend our gratitude for their significant contributions to the field.

Additionally, we leverage the GPT-2 and Vision Transformer (ViT) models developed by Hugging Face, which have been instrumental in advancing our project's capabilities. Our sincere thanks go to the Hugging Face team for making such powerful tools accessible to the broader research community.

Owner

  • Name: Arvind Rajan
  • Login: arvindrajan92
  • Kind: user
  • Location: Melbourne, Australia
  • Company: @dnstech

Data Scientist at @dnstech

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite using metadata below."
authors:
- family-names: "Rajan"
  given-names: "Arvind"
  orcid: "https://orcid.org/0000-0003-4829-5007"
title: "A PyTorch implementation of DTrOCR: Decoder-only Transformer for Optical Character Recognition"
repository-code: 'https://github.com/arvindrajan92/DTrOCR'
date-released: 2024-07-13
license: MIT

GitHub Events

Total
  • Issues event: 13
  • Watch event: 110
  • Delete event: 4
  • Issue comment event: 27
  • Push event: 3
  • Pull request review event: 4
  • Pull request event: 11
  • Fork event: 17
  • Create event: 7
Last Year
  • Issues event: 13
  • Watch event: 110
  • Delete event: 4
  • Issue comment event: 27
  • Push event: 3
  • Pull request review event: 4
  • Pull request event: 11
  • Fork event: 17
  • Create event: 7

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 8
  • Total pull requests: 7
  • Average time to close issues: 3 months
  • Average time to close pull requests: 19 days
  • Total issue authors: 7
  • Total pull request authors: 1
  • Average comments per issue: 2.38
  • Average comments per pull request: 0.14
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 7
Past Year
  • Issues: 8
  • Pull requests: 7
  • Average time to close issues: 3 months
  • Average time to close pull requests: 19 days
  • Issue authors: 7
  • Pull request authors: 1
  • Average comments per issue: 2.38
  • Average comments per pull request: 0.14
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 7
Top Authors
Issue Authors
  • arvindrajan92 (7)
  • heinrichI (2)
  • quoclam-doit (1)
  • jprorikon (1)
  • SMR-AIT (1)
  • wzgwy (1)
  • ka-fu-chi-no (1)
  • kasuba-badri-vishal (1)
  • Mistsink (1)
  • Kimchangheon (1)
  • donjuanpond (1)
  • ALIKSARKAR (1)
Pull Request Authors
  • dependabot[bot] (7)
  • arvindrajan92 (6)
  • lalitshankarchowdhury (1)
  • Cung-AGA (1)
Top Labels
Issue Labels
stale (8) closed (8) enhancement (6) question (2) documentation (1) bug (1) wontfix (1)
Pull Request Labels
dependencies (7) python (6) invalid (1) stale (1) closed (1)

Dependencies

requirements.txt pypi
  • torch ==2.3.1
  • transformers ==4.42.4
.github/workflows/python-app.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/greetings.yml actions
  • actions/first-interaction v1 composite
.github/workflows/stale.yml actions
  • actions/stale v9 composite