DocLayout-YOLO
raw JSON → 0.0.4 verified Fri May 01 auth: no python
DocLayout-YOLO is an efficient and robust document layout analysis method based on YOLO, optimized for detecting document elements like text, tables, figures, and titles. Current version 0.0.4, pre-release stage with irregular cadence.
pip install doclayout-yolo Common errors
error ModuleNotFoundError: No module named 'ultralytics' ↓
cause Ultralytics is a required dependency not installed automatically in some environments.
fix
Run
pip install ultralytics in your environment. error FileNotFoundError: [Errno 2] No such file or directory: '.../doclayout_yolo/model/doclayout_yolo.pt' ↓
cause Model weights are missing because automatic download failed (e.g., no internet) or custom path is incorrect.
fix
Ensure internet connectivity on first run, or manually download the model and set
model_path argument. Warnings
gotcha Model weights are downloaded automatically on first use. Ensure internet access or pre-download the weights to avoid runtime errors. ↓
fix Run offline: download model file manually and specify model path via `detect_layout(image, model_path='path/to/model.pt')`.
gotcha The library is in early stage (v0.0.4); the API may change without notice. Pin the exact version in requirements. ↓
fix Use `pip install doclayout-yolo==0.0.4` and check release notes before upgrading.
deprecated The function `detect_layout` was introduced in v0.0.2; older versions required direct import of `DocLayoutYOLO` class and manual inference. ↓
fix Upgrade to >=0.0.2 and use `from doclayout_yolo import detect_layout`.
Imports
- detect_layout
from doclayout_yolo import detect_layout - DocLayoutYOLO wrong
from doclayout_yolo import DocLayoutYOLO as DLYcorrectfrom doclayout_yolo import DocLayoutYOLO
Quickstart
from doclayout_yolo import detect_layout
# Replace with your image path
image_path = 'document.jpg'
results = detect_layout(image_path)
print(results)