Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,8 +13,24 @@ pipe_prior.to("cuda")
|
|
| 13 |
pipe = KandinskyPipeline.from_pretrained("kandinsky-community/kandinsky-2-1", torch_dtype=torch.float16)
|
| 14 |
pipe.to("cuda")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
@spaces.GPU()
|
| 17 |
def blend(img1, img2, slider):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# add all the conditions we want to interpolate, can be either text or image
|
| 19 |
images_texts = [img1, img2]
|
| 20 |
|
|
|
|
| 13 |
pipe = KandinskyPipeline.from_pretrained("kandinsky-community/kandinsky-2-1", torch_dtype=torch.float16)
|
| 14 |
pipe.to("cuda")
|
| 15 |
|
| 16 |
+
|
| 17 |
+
@spaces.GPU()
|
| 18 |
+
def squarify_image(img):
|
| 19 |
+
if(img.height > img.width): bg_size = img.height
|
| 20 |
+
else: bg_size = img.width
|
| 21 |
+
bg = Image.new(mode="RGB", size=(bg_size,bg_size), color="white")
|
| 22 |
+
bg.paste(img, ( int((bg.width - bg.width)/2), 0) )
|
| 23 |
+
|
| 24 |
+
return bg
|
| 25 |
+
|
| 26 |
@spaces.GPU()
|
| 27 |
def blend(img1, img2, slider):
|
| 28 |
+
img1.thumbnail((1024, 1024))
|
| 29 |
+
img2.thumbnail((1024, 1024))
|
| 30 |
+
|
| 31 |
+
img1 = squarify_image(img1)
|
| 32 |
+
img2 = squarify_image(img2)
|
| 33 |
+
|
| 34 |
# add all the conditions we want to interpolate, can be either text or image
|
| 35 |
images_texts = [img1, img2]
|
| 36 |
|