Files
Frank Schwenk a60a18a253 chore: add Ruff and apply formatting across codebase
Introduce ruff lint/format config, expand .gitignore, and reformat Python sources.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-18 17:34:14 +02:00

82 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""Orange pipeline: rembg variants composited over backgrounds and originals."""
from pathlib import Path
from imagepipeline import Pipeline
INPUT = Path("/home/frank/pics/20260704_Hellraisers und The Shape Schlossplatz/darktable_exported")
OUTPUT_BASE = Path.home() / "pipeline_output"
# Reuse outputs from a previous run or external folder (key = step id, e.g. rembg_01).
EXISTING_OUTPUTS: dict[str, Path] = {}
# Resume an aborted run: point to its output root folder (or None for a fresh run).
CONTINUE_FROM: Path | None = None
COLOR1 = "#AA4E00"
COLOR2 = "#EDDD93"
# COLOR1 = #AA4E00 -> 170,78,0; COLOR2 = #EDDD93 -> 237,221,147
GMIC_DROP_SHADOW = "-fx_drop_shadow3d 0,0,0,10,1,1,2,0.5,237,221,147,200,0"
GMIC_BWRECOLOR = (
"-fx_bwrecolorize 0,0,0,0,0,1,0,2,237,221,147,255,170,78,0,255,"
"158,137,189,255,224,191,228,255,170,78,0,255,255,255,255,255,255,255,"
"255,255,170,78,0,255"
)
GMIC_GRADIENT_A = (
'-fx_custom_gradient 0,0,0,1,2,1,0,128,100,100,2,0,1,0,"",1,0,170,78,0,255,'
"237,221,147,255,255,255,0,255,255,255,255,255,0,255,255,255,0,255,0,255,0,0,"
"255,255,128,128,128,255,255,0,255,255,0,0,0,0"
)
GMIC_GRADIENT_B = (
'-fx_custom_gradient 0,0,0,1,2,1,0,128,100,100,2,0,1,0,"",1,0,237,221,147,255,'
"170,78,0,255,255,255,0,255,255,255,255,255,0,255,255,255,0,255,0,255,0,0,"
"255,255,128,128,128,255,255,0,255,255,0,0,0,0"
)
def main() -> None:
with Pipeline(
name="orange",
input_dir=INPUT,
output_base=OUTPUT_BASE,
existing_outputs=EXISTING_OUTPUTS or None,
continue_from=CONTINUE_FROM,
) as p:
rembg_out = p.step("rembg", inputs="input")
grayscale = p.step("gmic_grayscale", inputs="input")
rembg_shadow = p.step("gmic", inputs=rembg_out, command=GMIC_DROP_SHADOW)
rembg_bwrecolor = p.step("gmic", inputs=rembg_out, command=GMIC_BWRECOLOR)
color_bg = p.step("imagemagick_fill", inputs="input", color1=COLOR1)
# combine: original, rembg (drop shadow), rembg
shadow_mid = p.step("composite", inputs=["input", rembg_shadow])
p.step("composite", inputs=[shadow_mid, rembg_out])
# combine: original, rembg (bw recolorize @ 50%), rembg
bw_mid = p.step(
"composite",
inputs=["input", rembg_bwrecolor],
foreground_opacity=0.5,
)
p.step("composite", inputs=[bw_mid, rembg_out])
# combine: original (grayscale), rembg
p.step("composite", inputs=[grayscale, rembg_out])
# combine: color background, rembg (drop shadow), rembg
shadow_color_mid = p.step("composite", inputs=[color_bg, rembg_shadow])
p.step("composite", inputs=[shadow_color_mid, rembg_out])
output_root = p.run()
print(f"Pipeline finished. Output: {output_root}")
if __name__ == "__main__":
main()