layout-parser
layout-parser copied to clipboard
table parse using tesseract
Hi, first I would like to thank you for this amazing project , I am asking if you could provide some details about how can I run the ocr table notebook using tesseract ocr , in your example you are using google vision api, thank you
To get the layout using Tesseract use the following:
ocr_agent = lp.TesseractAgent(languages='eng')
res = ocr_agent.detect(image, return_response=True)
layout = ocr_agent.gather_data(res, agg_level=lp.TesseractFeatureType.WORD)
and the rest of the tutorial is same
Update I have fixed the error you can see at the bottom!
Original message
Hi there, thanks for the update, this doesn't work for me however:
I get the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/var/folders/p6/v7jprs6526gcc3dqw6rhjj8w0000gn/T/ipykernel_20263/3263327315.py in <module>
----> 1 ocr_agent = lp.TesseractAgent(languages='eng')
/usr/local/lib/python3.9/site-packages/layoutparser/file_utils.py in __getattr__(self, name)
224 value = getattr(module, name)
225 else:
--> 226 raise AttributeError(f"module {self.__name__} has no attribute {name}")
227
228 setattr(self, name, value)
AttributeError: module layoutparser has no attribute TesseractAgent
It looks like there is some code for the TesseractAgent
but I just can't work out how to import it.
Any suggestions?
Solution
I first needed to import the ocr tool kit and the models:
!pip3 install "layoutparser[ocr]"
!pip3 install "layoutparser[layoutmodels]"