File size: 593 Bytes
01ab3a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: © 2022 lox9973

import torch

def patch_conv(klass):
	init = klass.__init__
	def __init__(self, *args, **kwargs):
		return init(self, *args, **kwargs, padding_mode='circular')
	klass.__init__ = __init__

for klass in [torch.nn.Conv2d, torch.nn.ConvTranspose2d]:
	patch_conv(klass)

from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=YOUR_TOKEN)
pipe.to("cuda")
pipe("a photograph of an astronaut riding a horse")["sample"][0].save("output.png")