Image Pipeline Playground
{
"version": 1,
"name": "custom-python-sepia",
"description": "Load anna-portrait, then apply a sepia look via inline Custom Python (requires trust before Run).",
"seed": 0,
"sampleCount": 1,
"graph": {
"nodes": [
{
"id": "load-1",
"type": "load_image",
"params": { "sample": "anna-portrait" },
"position": { "x": 0, "y": 0 }
},
{
"id": "custom-1",
"type": "custom_python",
"params": {
"code": "def process(image, seed=0):\n # Simple sepia tone (BGR uint8).\n # log(...) lines show up in the Script log panel below.\n log(\"sepia start\", \"seed=\", seed)\n log(\"input\", image)\n\n b = image[:, :, 0].astype(np.float32)\n g = image[:, :, 1].astype(np.float32)\n r = image[:, :, 2].astype(np.float32)\n tr = 0.393 * r + 0.769 * g + 0.189 * b\n tg = 0.349 * r + 0.686 * g + 0.168 * b\n tb = 0.272 * r + 0.534 * g + 0.131 * b\n out = image.copy()\n out[:, :, 0] = np.clip(tb, 0, 255).astype(np.uint8)\n out[:, :, 1] = np.clip(tg, 0, 255).astype(np.uint8)\n out[:, :, 2] = np.clip(tr, 0, 255).astype(np.uint8)\n\n log(\"sepia done\", out)\n return out\n"
},
"position": { "x": 220, "y": 0 }
}
],
"edges": [
{
"id": "e1",
"source": "load-1",
"source_port": "image",
"target": "custom-1",
"target_port": "image"
}
]
}
}