Instructions to use juliozhao/DocLayout-YOLO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use juliozhao/DocLayout-YOLO with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("juliozhao/DocLayout-YOLO", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
Simplify dataset download instructions
Browse files
README.md
CHANGED
|
@@ -64,34 +64,18 @@ The four downstream benchmarks are released as separate dataset repositories, ea
|
|
| 64 |
|
| 65 |
```python
|
| 66 |
# pip install huggingface_hub
|
| 67 |
-
from pathlib import Path
|
| 68 |
from huggingface_hub import snapshot_download
|
| 69 |
|
| 70 |
-
def flatten_shards(root):
|
| 71 |
-
"""Move shard_NN/* back into images/ resp. labels/ (D4LA, M6Doc only)."""
|
| 72 |
-
root = Path(root)
|
| 73 |
-
for sub in ("images", "labels"):
|
| 74 |
-
d = root / sub
|
| 75 |
-
for shard in sorted(d.glob("shard_*")):
|
| 76 |
-
for f in shard.iterdir():
|
| 77 |
-
target = d / f.name
|
| 78 |
-
if target.exists():
|
| 79 |
-
raise FileExistsError(target) # names are unique across shards
|
| 80 |
-
f.rename(target)
|
| 81 |
-
shard.rmdir()
|
| 82 |
-
|
| 83 |
for repo, local in [
|
| 84 |
("juliozhao/D4LA", "D4LA"), # keep these exact directory names
|
| 85 |
-
("juliozhao/M6Doc", "m6doc"), # (the
|
| 86 |
("juliozhao/HJDataset", "HJDataset"),
|
| 87 |
("juliozhao/PRIMA-LAD", "prima-lad"),
|
| 88 |
]:
|
| 89 |
-
snapshot_download(repo, repo_type="dataset", local_dir=local
|
| 90 |
-
ignore_patterns=["v1.zip"])
|
| 91 |
-
flatten_shards(local)
|
| 92 |
```
|
| 93 |
|
| 94 |
-
|
| 95 |
|
| 96 |
## Usage
|
| 97 |
|
|
|
|
| 64 |
|
| 65 |
```python
|
| 66 |
# pip install huggingface_hub
|
|
|
|
| 67 |
from huggingface_hub import snapshot_download
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
for repo, local in [
|
| 70 |
("juliozhao/D4LA", "D4LA"), # keep these exact directory names
|
| 71 |
+
("juliozhao/M6Doc", "m6doc"), # (the val/train scripts depend on them)
|
| 72 |
("juliozhao/HJDataset", "HJDataset"),
|
| 73 |
("juliozhao/PRIMA-LAD", "prima-lad"),
|
| 74 |
]:
|
| 75 |
+
snapshot_download(repo, repo_type="dataset", local_dir=local)
|
|
|
|
|
|
|
| 76 |
```
|
| 77 |
|
| 78 |
+
Each repository is ready to use as-is: the split lists point to the actual file locations, so no post-processing is needed after download.
|
| 79 |
|
| 80 |
## Usage
|
| 81 |
|