1#!/usr/bin/env bash
2#
3# build.sh: the images for "Drunk in Paris"
4#
5# A night of French gothic romance, named after the short Type O Negative track on
6# "Life Is Killing Me" (2003): ten chapters of three paintings each, thirty couples in all. The
7# scenes are sensual but not explicit, they are original inventions, and every figure is an
8# invented adult.
9#
10# Track: https://typeonegative.fandom.com/wiki/Drunk_in_Paris
11# Model: https://replicate.com/black-forest-labs/flux-3-image
12#
13# Settings:
14# Prompt plain, detailed sentences; web grounding is switched off so the model invents its
15# own faces and imagery
16# Size 2:3 portrait throughout; add `wide <chapter>-<painting>` below for a 3:2 spread
17#
18# Usage: ./build.sh [options] (REPLICATE_API_TOKEN must be set)
19# -p, --part N[,N...] only these chapters (1-10)
20# -k, --shot N[,N...] only these paintings (1-3)
21# -r, --resolution RES 768sq, 1k, 1.5k, 2k or 4k (default 1.5k)
22# -j, --jobs N parallel predictions (default 4)
23# -f, --force render paintings that already exist
24# -n, --dry-run print the prompts and payloads, generate nothing
25# -h, --help
26#
27# Output: drunk-in-paris-<chapter>-<painting>.jpg next to this file.
28# FLUX 3 has no seed input, so a rerun gives new takes on the same prompts; keep the images you
29# like, they are skipped. When all 30 exist, the post's `draft` flag is cleared.
30
31set -Eeuo pipefail
32
33HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
34ROSE="${ROSE_PY:-$HERE/../../../rose.py}"
35
36MODEL="black-forest-labs/flux-3-image"
37RESOLUTION="1.5k"
38PORTRAIT="2:3"
39LANDSCAPE="3:2"
40JOBS=4
41FORMAT="jpg"
42QUALITY=92
43FORCE=0
44DRY=0
45PART_ONLY=""
46SHOT_ONLY=""
47
48PARTS=10
49SHOTS=3
50
51# ---------------------------------------------------------------------------------------
52# The look, reused in every prompt
53# ---------------------------------------------------------------------------------------
54STYLE="A luminous, romantic digital oil painting in a French gothic style, with a polished concept \
55art finish, rich brushwork, deep shadows, crimson and plum accents, and Belle Epoque Paris detail."
56
57CLOSING="The mood is sensual, tender and elegant, with no nudity. Beautiful faces, natural \
58anatomy and graceful hands. A single full-bleed painting without text, lettering or borders."
59
60FF="Two adult women in their thirties, a couple."
61MF="A woman and a man, both adults in their thirties, a couple."
62
63# ---------------------------------------------------------------------------------------
64# Ten chapters, three paintings each. shot <chapter> <painting> <FF|MF> "<scene>"
65# `wide <chapter-painting>...` renders those as landscape spreads
66# ---------------------------------------------------------------------------------------
67declare -A PAIR SCENE WIDE
68shot() { PAIR["$1-$2"]=$3; SCENE["$1-$2"]=$4; }
69wide() { local key; for key in "$@"; do WIDE["$key"]=1; done; }
70
71# I. L'Apéritif
72shot 1 1 FF "They sit close at a round marble table on a Paris cafe terrace at night, foreheads \
73touching, eyes locked, red lips slightly parted. One has long ink-black hair, the other auburn \
74curls, both in black lace dresses. Two glasses of red wine, gas street lamps, fine rain falling \
75beyond the awning."
76shot 1 2 MF "Across a marble cafe table he lifts her hand to his lips while she watches him with \
77half-closed eyes and a slow smile. She wears a crimson corset gown and long wavy black hair, he a \
78black frock coat. Candle, wine, the Eiffel Tower glowing in the night behind them."
79shot 1 3 FF "In a candlelit cafe booth she playfully holds a sugar cube to her companion's lips \
80over two glasses of emerald absinthe. Platinum blonde finger waves and a jet black bob, velvet \
81gowns in bottle green and black, a green glow on their faces."
82
83# II. Montmartre
84shot 2 1 FF "They embrace halfway up a steep stone stairway in Montmartre at night, noses \
85touching. Red curls and long silver hair, long black coats open over lace dresses. An old iron \
86street lamp, wet steps, mist, the white domes of Sacre-Coeur above them."
87shot 2 2 MF "In a candlelit attic studio a painter in a loose white shirt gently lifts the chin of \
88his model, who is wrapped in draped burgundy silk with bare shoulders. An easel with her portrait, \
89candles, a tall arched window over moonlit rooftops."
90shot 2 3 FF "In an artist's attic one traces the jawline of the other with a paint-stained finger, \
91their faces very close. A dark-skinned woman with cropped curls and a pale woman with long dark \
92hair, ivory silk slip dress and black lace robe. Canvases, candlelight, moonlit window."
93
94# III. Le Chat Noir
95shot 3 1 FF "In a cabaret dressing room one stands behind the other, fastening a black velvet \
96choker around her neck and brushing her ear with her lips; both are reflected in a gilded mirror \
97ringed with warm bulbs. Black corsets, feather boas, lipsticks on the vanity."
98shot 3 2 FF "They recline together on a red velvet chaise longue, almost kissing. Black finger \
99waves and wine red hair, black and scarlet sequin gowns, long satin gloves. A sleek black cat \
100watches from the armrest, red curtains, drifting smoke."
101shot 3 3 MF "A passionate tango on a small cabaret stage, faces a breath apart, her leg wrapped \
102elegantly in the slit of a black sequin gown, his tuxedo bow tie hanging loose. A single red \
103spotlight, velvet curtains, smoke."
104
105# IV. L'Opéra
106shot 4 1 MF "Masked, they waltz through a gilded baroque ballroom, lips almost touching behind \
107black lace masks. A black and crimson gown swirls around his black tailcoat. Crystal chandeliers, \
108candlelight, blurred dancers far behind."
109shot 4 2 FF "In a private red velvet opera box one lowers her lace mask to whisper into the other's \
110ear, who closes her eyes and smiles. Midnight blue and emerald ball gowns, long black opera \
111gloves, champagne coupes, candlelight."
112shot 4 3 FF "They slow dance on the grand marble staircase of the Paris opera house, one's hand on \
113the other's open back. Black silk and ivory silk gowns with long trains, venetian masks, bronze \
114candelabra."
115
116# V. La Seine
117shot 5 1 MF "They kiss beneath a black umbrella on an old stone bridge over the Seine in pouring \
118rain. Her red dress is the only bright colour, he wears a long dark coat. Street lamps reflected \
119in the wet cobbles and the river, Notre-Dame in the mist."
120shot 5 2 FF "On the stone quay of the Seine two women dance in each other's arms, laughing, wet \
121hair and long black chiffon gowns caught by the wind, the full skirts sweeping the ground and \
122completely covering their legs and feet, a wine bottle left on the stones. Moonlight on the water, \
123the Pont Alexandre III behind them."
124shot 5 3 FF "Wrapped together in one deep red velvet cloak they sit on the bank of the Seine, cheek \
125to cheek, eyes closed. An auburn braid and a short black bob. A lantern beside them, a misty stone \
126bridge, the Eiffel Tower far away."
127
128# VI. La Galerie
129shot 6 1 FF "A stolen kiss between two white marble statues in a dim museum gallery. Black lace \
130blouses and long skirts, one with her hair pinned up, one with it falling loose. Huge gilded \
131frames, a shaft of moonlight from a tall window."
132shot 6 2 MF "Pressed close between tall shelves of an antique Paris bookshop at night, she with \
133black hair and round spectacles, he with a short beard, their eyes locked, her hand on his \
134waistcoat. A single candle, old leather books, a library ladder."
135shot 6 3 FF "In a glass roofed Parisian covered passage at night she draws the other close by the \
136ribbon of her choker, both smiling softly. An East Asian woman with long straight black hair and \
137a redhead, silk evening dresses, glowing globe lamps, a mosaic floor."
138
139# VII. Le Carrosse
140shot 7 1 MF "Inside a horse drawn carriage with red velvet seats they sit close and share a gentle \
141kiss, her long black Victorian gown and his black frock coat and cravat, her gloved hand resting \
142on his lapel. Street lamps pass by the rain streaked window."
143shot 7 2 FF "In a velvet lined carriage at night one rests her head on the other's bare shoulder, \
144eyes closed, their gloved fingers intertwined. Black fur stoles, lace gloves, a champagne bottle, \
145the lights of a boulevard through the window."
146shot 7 3 FF "Beside a black carriage before a baroque Paris mansion, one bows to kiss the inside of \
147the other's wrist as she steps down. Long black and burgundy trains, wet cobbles, a black horse, \
148lanterns in the fog."
149
150# VIII. La Cave
151shot 8 1 FF "In a vaulted stone wine cellar by candlelight they share one glass of red wine, a drop \
152on her lower lip that the other is about to wipe away with her thumb. Black leather corsets with \
153lace sleeves, smouldering eyes, old barrels."
154shot 8 2 MF "She leans back against an oak barrel in a candlelit cellar, eyes closed, as he kisses \
155her neck. Long red hair, a dark green velvet gown slipping from one shoulder, his black waistcoat \
156and rolled sleeves. Dusty bottles and dripping candles."
157shot 8 3 FF "In a candlelit stone alcove they sit knee to knee in black and wine red silk robes, \
158hands intertwined, faces close. One has black hair with a white streak, the other honey blonde \
159waves. Dark red roses, dripping wax."
160
161# IX. Les Toits
162shot 9 1 MF "Sitting close on a zinc Paris rooftop among chimney pots, sharing a bottle of wine, \
163they kiss under a starry sky. Her black lace dress, his open white shirt, the Eiffel Tower \
164glowing in the distance."
165shot 9 2 FF "On a wrought iron balcony at night she holds the other from behind and kisses her \
166bare shoulder; the other leans back with closed eyes. Satin slip dresses and a sheer black robe, \
167Haussmann facades, the Eiffel Tower, a full moon."
168shot 9 3 FF "Two elegant women in their fifties, one with silver hair and one with black, touch \
169foreheads on a rooftop terrace, smiling tenderly, champagne coupes in hand. Velvet gowns, a huge \
170moon over the domes of Paris."
171
172# X. L'Aube
173shot 10 1 FF "Waking in a Paris boudoir at dawn, they lie face to face under rumpled ivory satin \
174sheets drawn up to their shoulders, noses touching, with sleepy smiles and tangled hair. Rose \
175petals on the pillow, lace straps, a tall window with pale light."
176shot 10 2 FF "Lips almost touching, eyes closed, they lean over a pale marble cafe table at dawn. \
177One has long ink-black hair and black lace, the other wine red hair and a jewelled choker. A \
178crystal carafe of red wine, glasses and fallen dark red roses in front, a tall arched window with \
179Paris rooftops, soft clouds and a plum velvet curtain behind."
180shot 10 3 MF "At the open balcony doors at dawn she wears his white shirt over a black slip, he \
181holds her by the waist from behind, cheek to cheek. Coffee cups, a pink and violet sky over the \
182rooftops of Paris and the Eiffel Tower."
183
184
185# 9-3 shows an older couple, so it brings its own description
186PAIR["9-3"]=SELF
187
188# ---------------------------------------------------------------------------------------
189# Helpers
190# ---------------------------------------------------------------------------------------
191if [[ -t 2 ]]; then
192 B=$'\033[1m' D=$'\033[2m' R=$'\033[31m' G=$'\033[32m' Y=$'\033[33m' Z=$'\033[0m'
193else
194 B="" D="" R="" G="" Y="" Z=""
195fi
196say() { printf '%s\n' "$*" >&2; }
197die() { say "${R}error:${Z} $*"; exit 2; }
198usage() { sed -n '/^# Usage:/,/^# -h/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
199squash() { tr -s '[:space:]' ' '; }
200file_of() { printf '%s/drunk-in-paris-%d-%d' "$HERE" "$1" "$2"; } # chapter painting -> path, no extension
201have() { compgen -G "$(file_of "$1" "$2").*" >/dev/null; }
202
203shot_prompt() { # chapter-painting -> one-line prompt
204 local who=""
205 case ${PAIR[$1]} in
206 FF) who="$FF" ;;
207 MF) who="$MF" ;;
208 esac
209 printf '%s %s %s %s' "$STYLE" "$who" "${SCENE[$1]}" "$CLOSING" | squash
210}
211
212result() { # out_dir index -> the file rose.py saved for that prompt, if any
213 find "$1" -maxdepth 1 -type f -name "*-$(printf '%02d' "$2").*" 2>/dev/null | head -n1 || true
214}
215
216# ---------------------------------------------------------------------------------------
217# Options
218# ---------------------------------------------------------------------------------------
219while (($#)); do
220 case "$1" in
221 -p | --part) PART_ONLY="${2:?--part needs a value}"; shift 2 ;;
222 -k | --shot) SHOT_ONLY="${2:?--shot needs a value}"; shift 2 ;;
223 -r | --resolution) RESOLUTION="${2:?--resolution needs a value}"; shift 2 ;;
224 -j | --jobs) JOBS="${2:?--jobs needs a value}"; shift 2 ;;
225 -f | --force) FORCE=1; shift ;;
226 -n | --dry-run) DRY=1; shift ;;
227 -h | --help) usage; exit 0 ;;
228 *) die "unknown option: $1 (try --help)" ;;
229 esac
230done
231
232[[ -f "$ROSE" ]] || die "rose.py not found at $ROSE (set ROSE_PY)"
233command -v python3 >/dev/null || die "python3 is required"
234[[ -n "${REPLICATE_API_TOKEN:-}" ]] || die "REPLICATE_API_TOKEN is not set"
235
236if [[ -n "$PART_ONLY" ]]; then
237 IFS=',' read -r -a WANT <<<"$PART_ONLY"
238 for n in "${WANT[@]}"; do [[ "$n" =~ ^([1-9]|10)$ ]] || die "chapter must be 1-10, got '$n'"; done
239else
240 WANT=(1 2 3 4 5 6 7 8 9 10)
241fi
242if [[ -n "$SHOT_ONLY" ]]; then
243 IFS=',' read -r -a SHOT_WANT <<<"$SHOT_ONLY"
244 for n in "${SHOT_WANT[@]}"; do [[ "$n" =~ ^[1-3]$ ]] || die "painting must be 1-3, got '$n'"; done
245else
246 SHOT_WANT=(1 2 3)
247fi
248
249TMP="$(mktemp -d)"
250trap 'rm -rf "$TMP"' EXIT
251failed=0
252
253say "${B}Drunk in Paris${Z} ${D}${MODEL} · ${RESOLUTION}${Z}"
254
255# ---------------------------------------------------------------------------------------
256# One batch per format, so each gets its aspect ratio
257# ---------------------------------------------------------------------------------------
258for format in portrait landscape; do
259 todo=()
260 for m in "${WANT[@]}"; do
261 for k in "${SHOT_WANT[@]}"; do
262 is=portrait
263 [[ -n "${WIDE[$m-$k]:-}" ]] && is=landscape
264 [[ $is == "$format" ]] || continue
265 if ((FORCE || DRY)) || ! have "$m" "$k"; then todo+=("$m $k"); fi
266 done
267 done
268 ((${#todo[@]})) || continue
269
270 aspect="$PORTRAIT"
271 [[ $format == landscape ]] && aspect="$LANDSCAPE"
272 say ""
273 say "${B}${format}${Z} ${D}(${#todo[@]} painting(s), ${aspect})${Z}"
274 prompts="$TMP/$format.txt"
275 : >"$prompts"
276 for item in "${todo[@]}"; do
277 read -r m k <<<"$item"
278 shot_prompt "$m-$k" >>"$prompts"
279 printf '\n' >>"$prompts"
280 done
281
282 args=(replicate "$MODEL" --prompts-file "$prompts" --jobs "$JOBS" --timeout 900
283 --aspect-ratio "$aspect" --resolution "$RESOLUTION" --no-grounding
284 --output-format "$FORMAT" --output-quality "$QUALITY" --output-dir "$TMP/$format" --no-meta)
285 ((DRY)) && args+=(--dry-run)
286 if ! python3 "$ROSE" "${args[@]}"; then
287 say "${Y}some paintings failed, rerun to retry them${Z}"
288 failed=1
289 fi
290 ((DRY)) && continue
291
292 i=0
293 for item in "${todo[@]}"; do
294 i=$((i + 1))
295 read -r m k <<<"$item"
296 src="$(result "$TMP/$format" "$i")"
297 [[ -n "$src" ]] || continue
298 mv -f "$src" "$(file_of "$m" "$k").${src##*.}"
299 say "${G}saved${Z} drunk-in-paris-$m-$k.${src##*.}"
300 done
301done
302
303# ---------------------------------------------------------------------------------------
304# Publish the post once everything exists
305# ---------------------------------------------------------------------------------------
306if ((!DRY)); then
307 missing=0
308 for ((m = 1; m <= PARTS; m++)); do
309 for ((k = 1; k <= SHOTS; k++)); do have "$m" "$k" || missing=$((missing + 1)); done
310 done
311 if ((missing)); then
312 say "${Y}${missing} painting(s) still missing.${Z}"
313 elif [[ -f "$HERE/index.md" ]] && grep -q '^draft: true$' "$HERE/index.md"; then
314 sed -i 's/^draft: true$/draft: false/' "$HERE/index.md"
315 say "${G}All $((PARTS * SHOTS)) paintings exist: draft flag cleared in index.md.${Z}"
316 fi
317fi
318
319exit "$failed"