Skip to content

Commit eb107c0

Browse files
committed
Move marketing.py into hero_image/ and setup peotry deps
1 parent a628357 commit eb107c0

File tree

4 files changed

+963
-7
lines changed

4 files changed

+963
-7
lines changed

_internal/hero_image/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Marimo script that can be used to generate nice header images for articles.
2+
3+
```sh
4+
# ensure dependencies are install
5+
poetry install
6+
7+
# run the notebook
8+
poetry run marimo edit marketing.py
9+
```

_internal/marketing.py renamed to _internal/hero_image/marketing.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ def __():
2222

2323
@app.cell
2424
def __(font_name, font_size, mo, text):
25-
from PIL import Image, ImageDraw, ImageFont
26-
from io import BytesIO
27-
import os
2825
import base64
26+
import os
27+
from io import BytesIO
2928
from textwrap import dedent
3029

30+
from PIL import Image, ImageDraw, ImageFont
31+
3132
width = 1944
3233
height = 1024
3334
image = Image.new("RGB", (width, height), color="white")
3435
draw = ImageDraw.Draw(image)
3536
try:
36-
font = ImageFont.truetype(f"fonts/{font_name}.ttf", font_size)
37+
font = ImageFont.truetype(f"../fonts/{font_name}.ttf", font_size)
3738
except IOError:
3839
print("Couldn't load font")
3940
font = ImageFont.load_default(font_size)
@@ -115,10 +116,10 @@ def __(mo):
115116
@app.cell
116117
def __(os):
117118
from substrate import (
118-
Substrate,
119119
GenerateImage,
120-
StableDiffusionXLControlNet,
121120
RemoveBackground,
121+
StableDiffusionXLControlNet,
122+
Substrate,
122123
UpscaleImage,
123124
)
124125

@@ -157,9 +158,11 @@ def __(
157158
strength=0.6,
158159
num_images=1,
159160
)
161+
162+
upscale_prompt = form.value["upscale_prompt"]
160163
upscale = UpscaleImage(
161164
image_uri=controlnet.future.outputs[0].image_uri,
162-
prompt=f"{form.value["upscale_prompt"]} {prompt}",
165+
prompt=f"{upscale_prompt} {prompt}",
163166
output_resolution=2048,
164167
)
165168
res = substrate.run(upscale)
@@ -185,6 +188,7 @@ def __(controlnet, mask, mo, res, upscale):
185188
@app.cell
186189
def __(BytesIO, Image, ImageDraw, base64, font, height, text, width, x, y):
187190
import re
191+
188192
import numpy as np
189193
from PIL import ImageChops
190194

0 commit comments

Comments
 (0)