Skip to content

Comments

Integrate with huggingface#68

Open
not-lain wants to merge 3 commits intoOpenGVLab:mainfrom
not-lain:integrate-with-huggingface
Open

Integrate with huggingface#68
not-lain wants to merge 3 commits intoOpenGVLab:mainfrom
not-lain:integrate-with-huggingface

Conversation

@not-lain
Copy link

@not-lain not-lain commented Apr 2, 2024

this pr will mainly add 3 methods to the uniformerv2 models

  • save_pretrained
  • push_to_hub
  • from_pretrained : initialize and load the model weights

allowing your models to be easily integrated with huggingface using the PyTorchModelHubMixin class, I made this notebook https://colab.research.google.com/drive/1_H5LR5EclcBAhtyrarB_c49-TEceKoZU?usp=sharing explaining how to use it
by the end of the notebook all users can load your model simply by

!pip install -q git+https://github.com/not-lain/UniFormerV2.git@integrate-with-huggingface # or your main branch when this is merged
from slowfast.models.uniformerv2_model import VisionTransformer
new_model = VisionTransformer.from_pretrained("not-lain/uniformerv2_b16") 
# no more renitializing the model and manually downloading the weights

I also made a huggingface space further showcasing how to use this pr.

Why you should integrate your model with huggingface ?

  • easily save, load and push your model
  • Keep track on how many times your model has been downloaded by the community.
  • Automatic model card generation: the metadata in the card allows you to filter your searches easily to check how many UniFormerV2 models exist on the Hub .
  • Recommended: after this pr is merged we can open a pull request on this file to make the "UniFormerV2" library official on the Hub meaning better discoverability + possibility to add code snippets.

do not hesitate if you have any reviews on the pr or any questions.

Kind regards,
Hafedh Hichri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant