# PyTorchModelHubMixin Help

**URL:** <https://discuss.huggingface.co/t/pytorchmodelhubmixin-help/90261>\
**Category:** Beginners\
**Created:** [June 4, 2024, 11:09am UTC](https://discuss.huggingface.co/t/pytorchmodelhubmixin-help/90261 "2024-06-04T11:09:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GKYagami](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@GKYagami](https://discuss.huggingface.co/u/GKYagami)\
**Post date:** [June 4, 2024, 11:09am UTC](https://discuss.huggingface.co/t/pytorchmodelhubmixin-help/90261/1 "2024-06-04T11:09:11Z")

</div>

I need some help with uploading models to the Hugging Face repo to later access them with inference endpoints. I’m planning on training a custom DreamBooth model, but I’m confused about how to upload it. I guess I should be using [**PyTorchModelHubMixin**](https://huggingface.co/docs/hub/en/models-uploading), but I don’t really know how to use it in my notebook for this kind of model. Can someone please help me out?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [June 4, 2024, 6:14pm UTC](https://discuss.huggingface.co/t/pytorchmodelhubmixin-help/90261/2 "2024-06-04T18:14:11Z")

</div>

Hi,

Sure happy to help out. What does your model look like?

---

<div class="post-metadata">

**Author:** ![GKYagami](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@GKYagami](https://discuss.huggingface.co/u/GKYagami)\
**Post date:** [June 4, 2024, 6:42pm UTC](https://discuss.huggingface.co/t/pytorchmodelhubmixin-help/90261/3 "2024-06-04T18:42:48Z")

</div>

It’s basically this: [Google Colab](https://colab.research.google.com/github/ShivamShrirao/diffusers/blob/main/examples/dreambooth/DreamBooth_Stable_Diffusion.ipynb)

I managed to upload something just for testing, but I’m not really sure what to do with the above Colab notebook

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/1/a/1a507257907f53f7977a6d210cb622f198427ae5.png)

---

<div class="post-metadata">

**Author:** ![GKYagami](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@GKYagami](https://discuss.huggingface.co/u/GKYagami)\
**Post date:** [June 5, 2024, 3:39pm UTC](https://discuss.huggingface.co/t/pytorchmodelhubmixin-help/90261/4 "2024-06-05T15:39:30Z")

</div>

Hi @nielsr,

I would also like to know how to upload a ControlNet model to the hub and then send an image through the inference API as an input to the model

Control Net colab : [Google Colab](https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/controlnet.ipynb)

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [June 5, 2024, 8:32pm UTC](https://discuss.huggingface.co/t/pytorchmodelhubmixin-help/90261/5 "2024-06-05T20:32:14Z")

</div>

Hi,

As explained [here](https://huggingface.co/docs/hub/models-uploading#upload-from-a-library-with-built-in-support), if your model is available in a native library (like Diffusers or Transformers), you can use the following:

```python
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(model_path, safety_checker=None, torch_dtype=torch.float16).to("cuda")

# push to hub
pipe.push_to_hub("...")

```

This is explained here: [Push files to the Hub](https://huggingface.co/docs/diffusers/en/using-diffusers/push_to_hub).

However if you have a custom nn.Module, you can leverage the [PyTorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/en/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin). I don’t see anything custom in your notebook which means that you can just use the native methods.
