Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload tileable.py
#49
by
tobiuo
- opened
- tileable.py +19 -0
tileable.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SPDX-License-Identifier: MIT
|
2 |
+
# SPDX-FileCopyrightText: © 2022 lox9973
|
3 |
+
|
4 |
+
import torch
|
5 |
+
|
6 |
+
def patch_conv(klass):
|
7 |
+
init = klass.__init__
|
8 |
+
def __init__(self, *args, **kwargs):
|
9 |
+
return init(self, *args, **kwargs, padding_mode='circular')
|
10 |
+
klass.__init__ = __init__
|
11 |
+
|
12 |
+
for klass in [torch.nn.Conv2d, torch.nn.ConvTranspose2d]:
|
13 |
+
patch_conv(klass)
|
14 |
+
|
15 |
+
from diffusers import StableDiffusionPipeline
|
16 |
+
|
17 |
+
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=YOUR_TOKEN)
|
18 |
+
pipe.to("cuda")
|
19 |
+
pipe("a photograph of an astronaut riding a horse")["sample"][0].save("output.png")
|