xavctn / img2table

img2table is a table identification and extraction Python Library for PDF and images, based on OpenCV image processing
MIT License
577 stars 76 forks source link

gpu option for doctr #210

Open julian24bas opened 3 months ago

julian24bas commented 3 months ago

As far as I know, the only way to use doctr on gpu is by adding to(device) like this

from doctr.models import ocr_predictor, from_hub

reco_arch = from_hub('tilman-rassy/doctr-crnn-vgg16-bn-fascan-v1')
model = ocr_predictor(det_arch="db_resnet50", reco_arch=reco_arch, pretrained=True).to(device)

So there is no kw to be passed to doctr.

from img2table.ocr import DocTR

ocr = DocTR(detect_language=False, kw={"det_arch": "db_resnet50", "reco_arch": reco_arch, "pretrained": True})

Is there another way or could you add a gpu option like this?

ocr = DocTR(detect_language=False, device="cuda", kw={"det_arch": "db_resnet50", "reco_arch": reco_arch, "pretrained": True})
nissansz commented 2 months ago

How to use doctr? How to train?