Unstructured-IO / Unstructured-IO/unstructured
bug/NameError: name 'LayoutElements' is not defined
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 15.5k
- Forks
- 1.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 13
Description
Hello unstructured team,
I ran into a bug where the module: unstructured/partition/utils/ocr_models/paddle_ocr.py
Would return the bug described above.
Here was my fix:
in the document where I call partition_pdf()
I set the namespace like so:
import unstructured.partition.utils.ocr_models.paddle_ocr as paddle_ocr_modue
from unstructure_inference.inference.layoutelement import LayoutElements
paddle_ocr_module.LayoutElements = LayoutElements
I am not sure if this is a sustainable solution, and I am not sure why the module itself is not able to find the definition of LayoutElements itself without me manually setting the namespace.
I made sure to have TYPING dependency, and at some point I even removed the condition, neither of which worked.
Please let me know if I missed something during installation that is causing this.
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting unstructured/partition/utils/ocr_models/paddle_ocr.py and reproduce the NameError through partition_pdf(). Check how LayoutElements is expected to be imported and compare that with the reported caller-side namespace workaround. Done means the module resolves LayoutElements without requiring callers to modify its namespace; no test file is mentioned in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100