pythonpython-typingimporterrordoctr

How to run midee doctr in python file?


When I was trying to run the below code with python file :

import os
os.environ['USEA-TF'] ='1'

from doctr.io import DocumentFile
from doctr.models import ocr_predictor

model = ocr_predictor(pretrained=True)
document = DocumentFile.from_images('IM.jpg')

result = model(document)
result.show(document)
json_response = result.export()
print(json_response)

Getting this error :-

ImportError: cannot import name 'OrderedDict' from 'typing' (c:\users\shubham nagar\appdata\local\programs\python\python37\lib\typing.py)

How will I able to run in .py file


Solution

  • Try as in the code example below

    from doctr.io import DocumentFile
    from doctr.models import ocr_predictor
    import json
    
    model = ocr_predictor(det_arch = 'db_resnet50',    
                          reco_arch = 'crnn_vgg16_bn', 
                          pretrained = True)