stable-diffusion / tileable.py
tobiuo's picture
Upload tileable.py
01ab3a3
raw history blame
No virus
593 Bytes
# 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")