Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Official PyTorch implementation of DocLayout-YOLO.
Zhiyuan Zhao, Hengrui Kang, Bin Wang, Conghui He
To set up your environment, follow these steps:
conda create -n doclayout_yolo python=3.10
conda activate doclayout_yolo
pip install -e .
Note: If you only need the package for inference, you can simply install it via pip:
pip install doclayout-yolo
You can perform predictions using either a script or the SDK:
Script
Run the following command to make a prediction using the script:
python demo.py --model path/to/model --image-path path/to/image
SDK
Here is an example of how to use the SDK for prediction:
import cv2
from doclayout_yolo import YOLOv10
# Load the pre-trained model
model = YOLOv10("path/to/provided/model")
# Perform prediction
det_res = model.predict(
"path/to/image", # Image to predict
imgsz=1024, # Prediction image size
conf=0.2, # Confidence threshold
device="cuda:0" # Device to use (e.g., 'cuda:0' or 'cpu')
)
# Annotate and save the result
annotated_frame = det_res[0].plot(pil=True, line_width=5, font_size=20)
cv2.imwrite("result.jpg", annotated_frame)
We provide model fine-tuned on DocStructBench for prediction, which is capable of handing various document types. Model can be downloaded from here and example images can be found under assets/example
.
You also can use predict_single.py
for prediction with custom inference settings. For batch process, please refer to PDF-Extract-Kit.
Find your ultralytics config file (for Linux user in $HOME/.config/Ultralytics/settings.yaml)
and change datasets_dir
to project root path.
./layout_data
:Dataset | Download |
---|---|
D4LA | link |
DocLayNet | link |
the file structure is as follows:
./layout_data
├── D4LA
│ ├── images
│ ├── labels
│ ├── test.txt
│ └── train.txt
└── doclaynet
├── images
├── labels
├── val.txt
└── train.txt
Training is conducted on 8 GPUs with a global batch size of 64 (8 images per device), detailed settings and checkpoints are as follows:
Dataset | Model | DocSynth300K Pretrained? | imgsz | Learning rate | Finetune | Evaluation | AP50 | mAP | Checkpoint |
---|---|---|---|---|---|---|---|---|---|
D4LA | DocLayout-YOLO | ✗ | 1600 | 0.04 | command | command | 81.7 | 69.8 | checkpoint |
D4LA | DocLayout-YOLO | ✓ | 1600 | 0.04 | command | command | 82.4 | 70.3 | checkpoint |
DocLayNet | DocLayout-YOLO | ✗ | 1120 | 0.02 | command | command | 93.0 | 77.7 | checkpoint |
DocLayNet | DocLayout-YOLO | ✓ | 1120 | 0.02 | command | command | 93.4 | 79.7 | checkpoint |
The DocSynth300K pretrained model can be downloaded from here. Change checkpoint.pt
to the path of model to be evaluated during evaluation.
The code base is built with ultralytics and YOLO-v10.
Thanks for these great work!
FAQs
DocLayout-YOLO: an effecient and robust document layout analysis method.
We found that doclayout-yolo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.