om-ai-lab / OmDet

Real-time and accurate open-vocabulary end-to-end object detection
Apache License 2.0
1.53k stars 143 forks source link

Make sure Hugging Face download stats work, better discoverability #10

Closed NielsRogge closed 4 months ago

NielsRogge commented 4 months ago

Dear @P3ngLiu and team,

Thanks for this nice work! I see you already pushed the model to the hub which is great: https://huggingface.co/omlab/OmDet-Turbo_tiny_SWIN_T/tree/main, however currently download metrics aren't working for your model + there are no tags in the model card which means it's hard for people to find it.

I wrote a quick PoC to showcase that you can easily have integration with the 🤗 hub so that you can automatically load the OmDet model using from_pretrained (and push it using push_to_hub), track download number (similar to models in the Transformers library), and have a nice model card. It leverages the PyTorchModelHubMixin class which allows to inherits these methods.

Usage is as follows:

from omdet.omdet_v2_turbo.detector import OmDetV2Turbo

model = OmDetV2Turbo.from_pretrained("nielsr/omdet-v2-turbo-tiny-swin-tiny")

This means people don't need to manually download a checkpoint first in their local environment, it just loads it automatically from the hub. The safetensors format is used to ensure safe serialization of the weights rather than pickle.

To improve discoverability, we can add a "zero-shot-object-detection" tag to the model card similar to the ones here: https://huggingface.co/models?pipeline_tag=zero-shot-object-detection&sort=trending. I opened a PR for that here: https://huggingface.co/omlab/OmDet-Turbo_tiny_SWIN_T/discussions/1

Would you be interested in this integration?

Kind regards,

Niels ML Engineer @ HF 🤗

P3ngLiu commented 4 months ago

That's awesome! Thank you very much for integrating our omdet-turbo. This is exactly what we intended to do. I will merge this commit.

NielsRogge commented 4 months ago

Thanks so much for merging my PR! Could you try out running the add_hf.py script so that download metrics will work for your model? 🤗 (feel free to push to https://huggingface.co/omlab/OmDet-Turbo_tiny_SWIN_T rather than my user account, it will just create a new commit)

!pip install huggingface_hub
!huggingface-cli login
python add_hf.py