Add PyTorchModelHubMixin

#7
by nielsr HF staff - opened

Currently download metrics aren't working, this PR showcases the PyTorchModelHubMixin class which adds from_pretrained and push_to_hub capabilities to the model, along with download metrics.

The model is currently here: https://huggingface.co/nielsr/RMBG-1.4, but of course you could directly push to this repo

nielsr changed pull request status to open

@nielsr , It would be better to convert it to safetensors, I also tried to automate calling the model since cloning, then injecting the weights is really not efficient, check refs/pr/6

I have found 3 problems with the transformers library when working with custom architectures and i'm working to fix them. As for how you can build your own custom architecture for HF, you can read my blogpost to find out how: https://huggingface.co/blog/not-lain/custom-architectures-with-huggingface

Thanks, note that there are 2 ways to get download metrics:

  • either using the PyTorchModelHubMixin as shown in this PR.
  • either through the Transformers library, as shown in your PR (with trust_remote_code=True). Nice blog post btw!

@nielsr , I really didn't know about the metrics part, also, also thank youuu 🤗

BRIA AI org

@nielsr thanks! i integrated the PyTorchModelHubMixinn class according to your example.

Thanks a lot! Will close this one.

nielsr changed pull request status to closed

Sign up or log in to comment