Spaces:
Running
Running
feat: allow display in multi lines
Browse filesFormer-commit-id: fa14435e4bbedc1507ecebb125a1500f1374b098
- dalle_mini/helpers.py +3 -3
dalle_mini/helpers.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
from PIL import Image, ImageDraw, ImageFont
|
| 2 |
|
| 3 |
-
def captioned_strip(images, caption):
|
| 4 |
increased_h = 0 if caption is None else 48
|
| 5 |
w, h = images[0].size[0], images[0].size[1]
|
| 6 |
-
img = Image.new("RGB", (len(images)*w, h + increased_h))
|
| 7 |
for i, img_ in enumerate(images):
|
| 8 |
-
img.paste(img_, (i*w, increased_h))
|
| 9 |
|
| 10 |
if caption is not None:
|
| 11 |
draw = ImageDraw.Draw(img)
|
|
|
|
| 1 |
from PIL import Image, ImageDraw, ImageFont
|
| 2 |
|
| 3 |
+
def captioned_strip(images, caption=None, rows=1):
|
| 4 |
increased_h = 0 if caption is None else 48
|
| 5 |
w, h = images[0].size[0], images[0].size[1]
|
| 6 |
+
img = Image.new("RGB", (len(images)*w//rows, h*rows + increased_h))
|
| 7 |
for i, img_ in enumerate(images):
|
| 8 |
+
img.paste(img_, (i//rows*w, increased_h + (i % rows) * h))
|
| 9 |
|
| 10 |
if caption is not None:
|
| 11 |
draw = ImageDraw.Draw(img)
|