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:
- automatically inherits
from_pretrainedandpush_to_hubmethods - have better metadata
- make sure download stats work.
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:
- one could create a Gradio demo on 🤗 Spaces to showcase what the model can do.
- one can link the datasets to the models (by adding them to the model cards)
- one can link the models/datasets to the paper page (by including this link: https://huggingface.co/papers/2410.12628 in the model/dataset cards)
- the dataset viewer currently doesn't work for your datasets. See here on how to enable them: https://huggingface.co/docs/datasets/image_dataset#object-detection
Let me know whether you need any help!
Kind regards,
Niels from HF