Load a pytorch .pt file of a Unet/UnetCond Model with diffusers Conv2D and implement in Stable Diffusion Pipeline

We can use this model = UNet2DConditionModel.from_pretrained('path_to_model') to load a Unet model and then we can put this in a DiffusionPipeline.

I have trained a Unet from scratch in Pytorch with Conv2d(in_channels, out_channels, kernel_size, etc) and saved it into a .pt file.

Is there a way where I can load this .pt file in diffusers UNet2DConditionModel.from_pretrained('path_to_.pt_file') and then add it into the pipeline?

Hey @pranked03 I’m not sure I follow. Was the unet trained as a part of diffusers? If so and the weights are of the same format used in the diffusers unet, you should be able to use the standard pytorch weight loading methods on the pytorch checkpoint

No. I trained the unet of a diffusion model I made from scratch. So its a separate .pt file. Is it possible to load that unet model into the diffusers library?

hey @pranked03 sorry for the delay here, we can’t guarantee that you’ll be able to load it into diffusers. You’ll have to do the leg work yourself to convert the weights