Make sure download stats work on Hugging Face, improve metadata by NielsRogge · Pull Request #6 · opendatalab/DocLayout-YOLO (original) (raw)

Hi @wangbinDL,

Thanks for this nice work, great to see the models being released on the hub! Your paper was featured on the daily papers: https://huggingface.co/papers/2410.12628. Would be great to link the models to the paper.

To make download stats work, I wrote a PR similar to THU-MIG/yolov10#168 which I did for the YOLOv10 repository.

It leverages the PyTorchModelHubMixin developed by the 🤗 team to make sure a custom PyTorch model like yours:

Usage is as follows:

from doclayout_yolo import YOLOv10 from huggingface_hub import hf_hub_download

Load a pre-trained model

filepath = hf_hub_download(repo_id="juliozhao/DocLayout-YOLO-D4LA-from_scratch", filename="doclayout_yolo_d4la_imgsz1600_from_scratch.pt") model = YOLOv10(filepath)

One can optionally push this to the hub

model.push_to_hub("juliozhao/DocLayout-YOLO-D4LA-from_scratch")

Can now be reloaded as follows (and will increment download count)

model = YOLOv10.from_pretrained("juliozhao/DocLayout-YOLO-D4LA-from_scratch")

Besides that, some more suggestions to improve the HF release:

Let me know whether you need any help!

Kind regards,

Niels from HF