76 lines
2.5 KiB
Python
76 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Baxxter pipeline 2: composites using outputs from baxxter run 1."""
|
|
|
|
from pathlib import Path
|
|
|
|
from imagepipeline import Pipeline
|
|
|
|
INPUT = Path("/home/frank/pics/20260525_Shooting Baxxter Boys/darktable_exported")
|
|
OUTPUT_BASE = Path.home() / "pipeline_output"
|
|
|
|
# Previous run (pipeline_baxxter.py).
|
|
PREV = Path("/home/frank/pipeline_output/baxxter_260530102700")
|
|
|
|
# step_id -> folder from PREV. Third gmic step is gmic_03 here but reuses PREV/gmic_06.
|
|
EXISTING_OUTPUTS: dict[str, Path] = {
|
|
"rembg_01": PREV / "rembg_01",
|
|
"gmic_01": PREV / "gmic_01",
|
|
"gmic_02": PREV / "gmic_02",
|
|
"gmic_03": PREV / "gmic_06",
|
|
}
|
|
|
|
YELLOW = "#d7fd00"
|
|
|
|
# Commands only for step definition; reused steps are not executed.
|
|
GMIC_STEREO = "-gcd_stereo_img 0,0,2.028,1,1.714,3.06,4,1,0"
|
|
GMIC_DROP_SHADOW = "-fx_drop_shadow3d 0,0,0,10,1,1,2,0.5,252,10,222,200,0"
|
|
GMIC_JPR_SMOOTH = "-jpr_gradient_smooth 0,1.5"
|
|
|
|
|
|
def main() -> None:
|
|
with Pipeline(
|
|
name="baxxter_2",
|
|
input_dir=INPUT,
|
|
output_base=OUTPUT_BASE,
|
|
existing_outputs=EXISTING_OUTPUTS,
|
|
) as p:
|
|
rembg = p.step("rembg", inputs="input")
|
|
|
|
gmic_stereo = p.step("gmic", inputs=rembg, command=GMIC_STEREO)
|
|
gmic_shadow = p.step("gmic", inputs=rembg, command=GMIC_DROP_SHADOW)
|
|
gmic_smooth = p.step("gmic", inputs=rembg, command=GMIC_JPR_SMOOTH)
|
|
|
|
gmic_stereo_alpha = p.step(
|
|
"color_to_alpha", inputs=gmic_stereo, color="#000000"
|
|
)
|
|
yellow_bg = p.step("imagemagick_fill", inputs="input", color1=YELLOW)
|
|
|
|
gmic_smooth_alpha = p.step(
|
|
"color_to_alpha", inputs=gmic_smooth, color="#7f7f7f"
|
|
)
|
|
gmic_smooth_sized = p.step(
|
|
"imagemagick_scale_crop",
|
|
inputs=gmic_smooth_alpha,
|
|
scale=1.05,
|
|
)
|
|
|
|
# combine: original, gmic_01 (black to alpha), rembg
|
|
stereo_mid = p.step("composite", inputs=["input", gmic_stereo_alpha])
|
|
p.step("composite", inputs=[stereo_mid, rembg])
|
|
|
|
# combine: yellow background, gmic_02, rembg
|
|
shadow_mid = p.step("composite", inputs=[yellow_bg, gmic_shadow])
|
|
p.step("composite", inputs=[shadow_mid, rembg])
|
|
|
|
# combine: original, gmic_06 (#7f7f7f to alpha, scaled), rembg
|
|
smooth_mid = p.step("composite", inputs=["input", gmic_smooth_sized])
|
|
p.step("composite", inputs=[smooth_mid, rembg])
|
|
|
|
output_root = p.run()
|
|
|
|
print(f"Pipeline finished. Output: {output_root}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|