Skip to content
forked from mindee/doctr

docTR (Document Text Recognition) - a seamless, high-performing & accessible library for OCR-related tasks powered by Deep Learning.

Notifications You must be signed in to change notification settings

Scalable-DeFi/doctr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Template for your OCR API using docTR

Installation

You will only need to install Git, Docker and poetry. The container environment will be self-sufficient and install the remaining dependencies on its own.

Usage

Starting your web server

You will need to clone the repository first:

git clone https://github.com/mindee/doctr.git

then change in the api folder, where you can start your container:

make lock
make run

Once completed, your FastAPI server should be running on port 8080.

Documentation and swagger

FastAPI comes with many advantages including speed and OpenAPI features. For instance, once your server is running, you can access the automatically built documentation and swagger in your browser at: http://localhost:8080/docs

Using the routes

You will find detailed instructions in the live documentation when your server is up, but here are some examples to use your available API routes:

Text detection

Using the following image:

with this snippet:

import requests
with open('/path/to/your/img.jpg', 'rb') as f:
    data = f.read()
print(requests.post("http://localhost:8080/detection", files={'file': data}).json())

should yield

[{'box': [0.826171875, 0.185546875, 0.90234375, 0.201171875]},
 {'box': [0.75390625, 0.185546875, 0.8173828125, 0.201171875]}]

Text recognition

Using the following image: recognition-sample

with this snippet:

import requests
with open('/path/to/your/img.jpg', 'rb') as f:
    data = f.read()
print(requests.post("http://localhost:8080/recognition", files={'file': data}).json())

should yield

{'value': 'invite'}

End-to-end OCR

Using the following image:

with this snippet:

import requests
with open('/path/to/your/img.jpg', 'rb') as f:
    data = f.read()
print(requests.post("http://localhost:8080/ocr", files={'file': data}).json())

should yield

[{'box': [0.75390625, 0.185546875, 0.8173828125, 0.201171875],
  'value': 'Hello'},
 {'box': [0.826171875, 0.185546875, 0.90234375, 0.201171875],
  'value': 'world!'}]

About

docTR (Document Text Recognition) - a seamless, high-performing & accessible library for OCR-related tasks powered by Deep Learning.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 89.2%
  • Makefile 5.7%
  • Dockerfile 5.1%