#!/usr/bin/env bash # # build.sh: the images for "Black No. 1" # # A poetry-to-image project after "Black No. 1 (Little Miss Scare-All)" by Type O Negative # (written by Peter Steele, 1993). Here it becomes a gothic beauty magazine editorial: eight # movements of three plates each, twenty-four plates and twenty-four different women. The lyrics are # copyrighted and are not reproduced here; the scenes below are original interpretations. All models # are invented adults. Read the words at the source: # # Lyrics: https://genius.com/Type-o-negative-black-no-1-little-miss-scare-all-lyrics # Model: https://replicate.com/black-forest-labs/flux-3-image # Look: gothic beauty portraits, luxury fashion magazine photography # # Every plate is a head-and-neck beauty portrait: the make-up, hair, headpiece and neckwear # carry the look. # # Usage: ./build.sh [options] (REPLICATE_API_TOKEN must be set) # -p, --part N[,N...] only these movements (1-8) # -k, --shot N[,N...] only these plates (1-3) # -a, --aspect RATIO aspect ratio (default 4:5) # -r, --resolution RES 768sq, 1k, 1.5k, 2k or 4k (default 2k) # -j, --jobs N parallel predictions (default 4) # -f, --force regenerate plates that already exist # -n, --dry-run print the prompts and payloads, generate nothing # -h, --help # # Output: black-no-1--.jpg next to this file. # FLUX 3 has no seed input, so a rerun gives new takes on the same prompts; keep the images you # like, they are skipped. Web grounding is switched off so the model invents its own faces. # When all 24 plates exist, the post's `draft` flag is cleared. set -Eeuo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROSE="${ROSE_PY:-$HERE/../../../rose.py}" MODEL="black-forest-labs/flux-3-image" ASPECT="4:5" RESOLUTION="2k" JOBS=4 FORMAT="jpg" QUALITY=92 FORCE=0 DRY=0 PART_ONLY="" SHOT_ONLY="" PARTS=8 SHOTS=3 # --------------------------------------------------------------------------------------- # The look, reused in every prompt # --------------------------------------------------------------------------------------- STYLE="High fashion beauty photography for a luxury gothic magazine. Photorealistic, shot on a \ medium format camera with a 105mm portrait lens, shallow depth of field, masterful beauty \ lighting, deep velvety blacks, rich tonal range, natural skin texture with visible pores, razor \ sharp eyes with bright catchlights, magnificent professional goth make-up applied with precision: \ detailed eyeshadow, crisp eyeliner, full lashes, shaped brows and flawlessly painted lips. Refined \ colour grading." NEGATIVE="One single adult woman, alone in the frame. No hands, no arms. One full-bleed \ photograph: no text, no lettering, no logos, no magazine masthead, no borders, no collage, no \ watermark." # Framing, the same for every plate FRAME="Tight beauty portrait of the head and neck only: the whole head, hair or headpiece and the \ complete neck are inside the frame, cropped at the collarbones, the face large and in sharp focus." # --------------------------------------------------------------------------------------- # Eight movements, three plates each. shot # --------------------------------------------------------------------------------------- declare -A SCENE shot() { SCENE["$1-$2"]=$3; } # I. Raven Gloss shot 1 1 "A Japanese woman in her late twenties with a mirror-glossy blunt black bob and micro \ fringe, porcelain matte skin, razor-sharp graphic winged eyeliner and deep black-cherry lips, a \ high black patent leather collar encircling her neck. She gazes straight into the camera, serious \ and still. Crisp beauty-dish light against a seamless charcoal backdrop." shot 1 2 "A Nigerian woman in her thirties with deep dark skin and long jet black braids adorned \ with silver rings, metallic gunmetal smoky eyes, glossy black lips, tiny black crystals under the \ eyes and a tall stack of black beaded necklaces up her throat. Chin raised, regal. A single hard \ key light with a cool silver rim light." shot 1 3 "A Swedish woman in her forties with sleek jet black hair parted in the middle, ice-pale \ skin, bleached brows, dramatic charcoal smoky eyes and glossy black lips, a high sheer black \ organza collar. A commanding, level stare. Soft overhead light against a stark black backdrop." # II. Velvet Devotion shot 2 1 "A Mexican woman in her thirties with long black waves crowned by dark red roses, ornate \ black filigree eye make-up, oxblood lips, a wide black lace choker with a garnet drop. Eyes lifted \ in quiet devotion. Warm soft key light against a perfectly clean, plain, seamless dark charcoal \ studio backdrop." shot 2 2 "An Ethiopian woman in her late twenties with a voluminous halo of black coils, burnished \ plum eyeshadow, gold-flecked black lips, layers of antique silver chains around her neck above a \ midnight purple velvet collar. Serene and intense. Chiaroscuro light like an old master painting." shot 2 3 "A Tamil woman in her thirties with a thick black braid woven with black blossoms, \ dramatic winged kohl eyes with plum shadow, glossy black-wine lips, ornate oxidised silver \ earrings and a black velvet beaded collar. Looking up toward a shaft of warm light, devoted." # III. Lace and Moonlight shot 3 1 "A pale Korean woman in her twenties with long ash-black hair, translucent skin, soft \ silver-grey smoky eyes, glass-gloss berry black lips, a delicate black net veil across her eyes \ and a black lace choker. Lips slightly parted, a cool seductive gaze. Blue moonlight from one \ side." shot 3 2 "An Irish woman in her thirties with cascading deep auburn curls, freckled fair skin, \ emerald and black smoky eyes, dark plum lips and a high-necked black Chantilly lace collar. A \ seductive glance over her turned neck. Cold window moonlight." shot 3 3 "A Samoan woman in her thirties with long glossy black waves, bronze skin, iridescent \ teal-black eye make-up sweeping to the temples, black lips and a scalloped black lace collar with \ a dark pearl strand. A calm, powerful gaze. Deep blue night light with a silver rim." # IV. The Mourning Salon shot 4 1 "A Persian woman in her thirties with thick dark brows, dramatic elongated black \ eyeliner, matte burgundy lips, a small tilted Victorian mourning hat with a spotted black net veil \ and raven feathers, and a jet bead collar. A grave, magnetic stare. Soft window light on a dark \ damask background." shot 4 2 "A Black British woman in her fifties with a close-cropped silver afro, high cheekbones, \ violet-black eyeshadow, deep aubergine lips, jet drop earrings and a high black lace jabot collar \ with a cameo. Dignified and unsmiling. Elegant sculpted side light." shot 4 3 "A Chinese woman in her late twenties with an elaborate high black updo pinned with \ silver hair ornaments, red-black graphic eye make-up, a precise dark crimson lip and a tall \ ruffled black taffeta collar. A poised, serious three-quarter turn of the head. Soft salon light." # V. Leather and Chrome shot 5 1 "A Brazilian woman of African descent in her twenties with a shaved head, bold \ chrome-silver and black avant-garde eye make-up sweeping to the temples, black lips with a silver \ centre line and stacked silver neck rings. Fierce direct gaze. Hard flash with a violet gel." shot 5 2 "A Russian woman in her thirties with a platinum white sleek high ponytail, heavy black \ smoky eyes, nearly black lips and a wide black leather collar with silver buckles. Confident and \ provocative. Hard side light with red and blue gels in smoke." shot 5 3 "A Filipina woman in her late twenties with a black and violet split-dyed shag haircut, \ smudged deathrock eye make-up with fine drawn lines beneath the eyes, black lips, silver ear cuffs \ and a studded leather choker. A defiant stare. A single hard backlight against raw concrete." # VI. Crimson Vanity shot 6 1 "A Lebanese woman in her thirties with glossy dark finger waves, smouldering copper-black \ eyes, a perfect deep blood-red lip, a beauty mark, ruby drop earrings and a black velvet ribbon \ with a ruby at her throat. A slow seductive glance into the camera. Warm red-tinted glamour \ light." shot 6 2 "An Italian woman in her forties with dark upswept hair, long black winged liner, deep \ crimson and black smoky eyes, glossy black-red lips and a garnet and black lace collar. A knowing \ seductive gaze. Low amber lamp light." shot 6 3 "A South Asian Punjabi woman in her thirties with long straight black hair parted in the \ middle, extended graphic black eyeliner, blood-red and black smoky eyes reaching to the temples, \ glossy near-black lips and an ornate black lace choker. Intense and alluring. Deep red rim light." # VII. All Hallows shot 7 1 "A Peruvian Quechua woman in her thirties with two long black braids tied with black \ ribbons, burnt-orange and black smoky eyes, dark brick lips, a crown of black autumn leaves and a \ beaded black collar. Calm, piercing eyes. Golden lantern glow against deep blue dusk." shot 7 2 "A Moroccan woman in her late twenties with big glossy dark curls swept to one side, \ refined bronze-black cat eyes, espresso-black lips, elegant jet drop earrings and a high black \ velvet couture collar. A knowing half smile, sophisticated and understated. Soft side light \ against a seamless dark grey backdrop." shot 7 3 "A woman with albinism in her twenties with long white hair, pale lashes, striking black \ and silver eye make-up, black lips and a tall black raven-feather collar framing her neck. Solemn. \ A soft key light against a misty twilight blue." # VIII. The Black Coronation shot 8 1 "A Mongolian woman in her thirties with sleek black hair swept back under a spiked black \ metal halo crown, a band of black pigment painted across the eyes, rosy wind-flushed cheeks, black \ lips and a high structured black collar. Imperious, unblinking. Dramatic top light." shot 8 2 "An Aboriginal Australian woman in her thirties with rich brown skin and wavy dark hair, \ star-like silver crystals around smoky black eyes, deep mulberry lips and an ornate black filigree \ metal collar set with polished obsidian stones, fitted closely around her neck, bare shoulders. \ Majestic. Crisp rim light against a perfectly clean, plain, seamless light grey studio backdrop, \ completely empty, without smoke or haze." shot 8 3 "A Sudanese woman in her late twenties with very deep dark skin, a sculpted black crown \ of braids with black jewels, glossy black eye make-up, black lips and a tall column of black metal \ neck rings. The sovereign of the night, looking slightly down into the camera. One shaft of light \ in darkness." # --------------------------------------------------------------------------------------- # Helpers # --------------------------------------------------------------------------------------- if [[ -t 2 ]]; then B=$'\033[1m' D=$'\033[2m' R=$'\033[31m' G=$'\033[32m' Y=$'\033[33m' C=$'\033[36m' Z=$'\033[0m' else B="" D="" R="" G="" Y="" C="" Z="" fi say() { printf '%s\n' "$*" >&2; } die() { say "${R}error:${Z} $*"; exit 2; } usage() { sed -n '/^# Usage:/,/^# -h/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; } squash() { tr -s '[:space:]' ' '; } file_of() { printf '%s/black-no-1-%d-%d' "$HERE" "$1" "$2"; } # movement plate -> path, no extension have() { compgen -G "$(file_of "$1" "$2").*" >/dev/null; } shot_prompt() { # movement plate -> one-line prompt printf '%s %s %s %s' "$FRAME" "${SCENE[$1-$2]}" "$STYLE" "$NEGATIVE" | squash } result() { # out_dir index -> the file rose.py saved for that prompt, if any find "$1" -maxdepth 1 -type f -name "*-$(printf '%02d' "$2").*" 2>/dev/null | head -n1 || true } # --------------------------------------------------------------------------------------- # Options # --------------------------------------------------------------------------------------- while (($#)); do case "$1" in -p | --part) PART_ONLY="${2:?--part needs a value}"; shift 2 ;; -k | --shot) SHOT_ONLY="${2:?--shot needs a value}"; shift 2 ;; -a | --aspect) ASPECT="${2:?--aspect needs a value}"; shift 2 ;; -r | --resolution) RESOLUTION="${2:?--resolution needs a value}"; shift 2 ;; -j | --jobs) JOBS="${2:?--jobs needs a value}"; shift 2 ;; -f | --force) FORCE=1; shift ;; -n | --dry-run) DRY=1; shift ;; -h | --help) usage; exit 0 ;; *) die "unknown option: $1 (try --help)" ;; esac done [[ -f "$ROSE" ]] || die "rose.py not found at $ROSE (set ROSE_PY)" command -v python3 >/dev/null || die "python3 is required" [[ -n "${REPLICATE_API_TOKEN:-}" ]] || die "REPLICATE_API_TOKEN is not set" if [[ -n "$PART_ONLY" ]]; then IFS=',' read -r -a WANT <<<"$PART_ONLY" for n in "${WANT[@]}"; do [[ "$n" =~ ^[1-8]$ ]] || die "movement must be 1-8, got '$n'"; done else WANT=(1 2 3 4 5 6 7 8) fi if [[ -n "$SHOT_ONLY" ]]; then IFS=',' read -r -a SHOT_WANT <<<"$SHOT_ONLY" for n in "${SHOT_WANT[@]}"; do [[ "$n" =~ ^[1-3]$ ]] || die "plate must be 1-3, got '$n'"; done else SHOT_WANT=(1 2 3) fi TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT failed=0 say "${B}Black No. 1${Z} ${D}${MODEL} · ${ASPECT} · ${RESOLUTION}${Z}" # --------------------------------------------------------------------------------------- # Shoot everything that is still missing, in one batch # --------------------------------------------------------------------------------------- todo=() for m in "${WANT[@]}"; do for k in "${SHOT_WANT[@]}"; do if ((FORCE || DRY)) || ! have "$m" "$k"; then todo+=("$m $k"); fi done done if ((${#todo[@]})); then say "" say "${C}${B}the editorial${Z} ${D}(${#todo[@]} plate(s))${Z}" : >"$TMP/prompts.txt" for item in "${todo[@]}"; do read -r m k <<<"$item" shot_prompt "$m" "$k" >>"$TMP/prompts.txt" printf '\n' >>"$TMP/prompts.txt" done args=(replicate "$MODEL" --prompts-file "$TMP/prompts.txt" --jobs "$JOBS" --timeout 900 --aspect-ratio "$ASPECT" --resolution "$RESOLUTION" --no-grounding --output-format "$FORMAT" --output-quality "$QUALITY" --output-dir "$TMP/out" --no-meta) ((DRY)) && args+=(--dry-run) if ! python3 "$ROSE" "${args[@]}"; then say "${Y}some plates failed, rerun to retry them${Z}" failed=1 fi if ((!DRY)); then i=0 for item in "${todo[@]}"; do i=$((i + 1)) read -r m k <<<"$item" src="$(result "$TMP/out" "$i")" [[ -n "$src" ]] || continue mv -f "$src" "$(file_of "$m" "$k").${src##*.}" say "${G}saved${Z} black-no-1-$m-$k.${src##*.}" done fi fi # --------------------------------------------------------------------------------------- # Publish the post once everything exists # --------------------------------------------------------------------------------------- if ((!DRY)); then missing=0 for ((m = 1; m <= PARTS; m++)); do for ((k = 1; k <= SHOTS; k++)); do have "$m" "$k" || missing=$((missing + 1)); done done if ((missing)); then say "" say "${Y}${missing} plate(s) still missing.${Z}" elif [[ -f "$HERE/index.md" ]] && grep -q '^draft: true$' "$HERE/index.md"; then sed -i 's/^draft: true$/draft: false/' "$HERE/index.md" say "" say "${G}All $((PARTS * SHOTS)) plates exist: draft flag cleared in index.md.${Z}" fi fi exit "$failed"