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.
You will need to clone the repository first, go into api
folder and start the api:
git clone https://github.com/mindee/doctr.git
cd doctr/api
make run
Once completed, your FastAPI server should be running on port 8080.
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
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:
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]}]
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'}
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!'}]