opendatalab / DocLayout-YOLO

DocLayout-YOLO: Enhancing Document Layout Analysis through Diverse Synthetic Data and Global-to-Local Adaptive Perception
https://huggingface.co/spaces/opendatalab/DocLayout-YOLO
GNU Affero General Public License v3.0
140 stars 8 forks source link

Make sure download stats work on Hugging Face, improve metadata #6

Closed NielsRogge closed 8 hours ago

NielsRogge commented 2 days ago

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 https://github.com/THU-MIG/yolov10/pull/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

JulioZhao97 commented 1 day ago

Thank you very much for your suggestions! If there are updates I will let you know immediately.

wangbinDL commented 9 hours ago

Hi @NielsRogge

Thanks for your valuable suggestions. We've now:

Your assistance is greatly appreciated!

Best, Bin

NielsRogge commented 5 hours ago

Thanks, looking great!

Note that for download stats to work, you will need to run the code snippet above for each of the model repos (basically overwriting them). As the class now inherits from PyTorchModelHubMixin, a config.json along with safetensors weights will be pushed.

JulioZhao97 commented 5 hours ago

Thanks, looking great!

Note that for download stats to work, you will need to run the code snippet above for each of the model repos (basically overwriting them). As the class now inherits from PyTorchModelHubMixin, a config.json along with safetensors weights will be pushed.

Noted, thanks for your contribution again!