ChaoningZhang / MobileSAM

This is the official code for MobileSAM project that makes SAM lightweight for mobile applications and beyond!
Apache License 2.0
4.86k stars 505 forks source link

Add Hugging Face integration #136

Closed NielsRogge closed 9 months ago

NielsRogge commented 10 months ago

Hi @ChaoningZhang @qiaoyu1002 and team!

Thanks for this nice work. I wrote a quick PoC to showcase that you can easily have integration so that you can automatically load the various MobileSAM models using from_pretrained (and push them using push_to_hub), track download numbers for your models (similar to models in the Transformers library), and have nice model cards on a per-model basis. It leverages the PyTorchModelHubMixin class which allows to inherits these methods.

Usage is as follows:

from mobile_sam import MobileSAM

model = MobileSAM.from_pretrained("nielsr/mobilesam")

The corresponding model is here for now: https://huggingface.co/nielsr/mobilesam. We could move all checkpoints to separate repos on your account on https://hf.co if you're interested.

Would you be interested in this integration?

Kind regards,

Niels