This is a fork from https://github.com/hikopensource/DAVAR-Lab-OCR with modified setup script and added docker web service for LGPMA table extraction model inference.
Download model maskrcnn-lgpma-pub-e12-pub.pth
from Google Drive
and place it in models
directory.
- Run
setup.sh
locally and it should install and build all required components. - Then you can run web service using uvicorn
uvicorn src.web:app --host 0.0.0.0 --port 8000
- Run
docker build -f docker/Dockerfile -t <tag> .
- Then you can start the container with web service with
docker run -d -p 8000:8000 -t <tag>
When the web service is running, you can use http protocol to process table images or set processing device.
/extract_table_structure/
- returns json with the table data obtained from model./get_device/
- returns the name of the device used by model, either cpu or cuda./set_device/{device}/
- tries to set processing device asdevice
and returns json with currently used device and method output - either success or failure
import requests
filename = ...
with open(filename, "rb") as f:
response = requests.post(url="http://0.0.0.0:8000/extract_table_structure", files={"input_file": f})