Skip to content

Commit

Permalink
Implement initial support for *Graph Editor*.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 31, 2024
1 parent dbda4a1 commit d47d768
Show file tree
Hide file tree
Showing 10 changed files with 38,817 additions and 1,093 deletions.
1,784 changes: 694 additions & 1,090 deletions colour_hdri/examples/examples_advanced_processing_with_the_nodegraph.ipynb

Large diffs are not rendered by default.

613 changes: 613 additions & 0 deletions colour_hdri/network/graph_editor.py

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions colour_hdri/network/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ExecutionNode,
ParallelForMultiprocess,
PortGraph,
notify_process_state,
)

from colour_hdri.generation import double_sigmoid_anchored_function
Expand Down Expand Up @@ -244,6 +245,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
output_port,
)

self.connect(
"execution_input",
self.nodes["ConvertRawFileToDNGFile"],
"execution_input",
)
self.connect(
"raw_file_path",
self.nodes["ConvertRawFileToDNGFile"],
Expand Down Expand Up @@ -330,6 +336,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"path",
)

@notify_process_state
def process(self, **kwargs: Any) -> None:
"""
Process the node-graph.
Expand Down Expand Up @@ -536,6 +543,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
output_port,
)

self.connect(
"execution_input",
self.nodes["ConvertRawFileToDNGFile"],
"execution_input",
)
self.connect(
"raw_file_path",
self.nodes["ConvertRawFileToDNGFile"],
Expand Down Expand Up @@ -627,6 +639,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"path",
)

@notify_process_state
def process(self, **kwargs: Any) -> None:
"""
Process the node-graph.
Expand Down Expand Up @@ -736,6 +749,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
output_port,
)

self.connect(
"execution_input",
self.nodes["CreateImageStack"],
"execution_input",
)
self.connect(
"exr_file_paths",
self.nodes["CreateImageStack"],
Expand Down Expand Up @@ -782,6 +800,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"path",
)

@notify_process_state
def process(self, **kwargs: Any) -> None:
"""
Process the node-graph.
Expand Down Expand Up @@ -866,6 +885,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_node(node)

for connection in [
(
("NormaliseExposure", "execution_output"),
("ParallelForMultiprocess", "execution_input"),
),
(
("ParallelForMultiprocess", "loop_output"),
("WritePreviewImage", "execution_input"),
Expand All @@ -882,6 +905,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
output_port,
)

self.connect(
"execution_input",
self.nodes["NormaliseExposure"],
"execution_input",
)
self.connect(
"array",
self.nodes["NormaliseExposure"],
Expand Down Expand Up @@ -916,6 +944,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"task", _task_multiprocess_post_merge_hdr
)

@notify_process_state
def process(self, **kwargs: Any) -> None:
"""
Process the node-graph.
Expand Down Expand Up @@ -991,6 +1020,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
output_port,
)

self.connect(
"execution_input",
self.nodes["CreateBatches"],
"execution_input",
)
self.connect(
"array",
self.nodes["CreateBatches"],
Expand Down Expand Up @@ -1043,6 +1077,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"results", self.nodes["GraphPostMergeHDRI"], "array"
)

@notify_process_state
def process(self, **kwargs: Any) -> None:
"""
Process the node-graph.
Expand Down Expand Up @@ -1162,6 +1197,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
output_port,
)

self.connect(
"execution_input",
self.nodes["ParallelForMultiprocess"],
"execution_input",
)
self.connect(
"array",
self.nodes["ParallelForMultiprocess"],
Expand Down Expand Up @@ -1274,6 +1314,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"Watermark"
].set_input("include_exposure_information", False)

@notify_process_state
def process(self, **kwargs: Any) -> None:
"""
Process the node-graph.
Expand Down
26 changes: 24 additions & 2 deletions colour_hdri/network/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
ExecutionNode,
as_float_array,
batch,
notify_process_state,
ones,
orient,
required,
Expand Down Expand Up @@ -200,6 +201,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("dng_converter_arguments")
self.add_output_port("dng_file_path")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -272,6 +274,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_output_port("exif_tags")

@required("OpenImageIO")
@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand All @@ -285,7 +288,7 @@ def process(self, **kwargs: Any) -> None: # noqa: ARG002
self.log(f'"{path}" image does not exist!')
return

image, metadata = read_image_OpenImageIO(path, attributes=True)
image, metadata = read_image_OpenImageIO(path, additional_data=True)

input_colourspace = self.get_input("input_colourspace")
if isinstance(input_colourspace, str):
Expand Down Expand Up @@ -330,6 +333,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("bypass", False)

@required("OpenImageIO")
@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -401,6 +405,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_output_port("preview_path")

@required("OpenImageIO")
@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -450,6 +455,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("path")
self.add_input_port("bypass", False)

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -488,6 +494,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("bypass", False)
self.add_output_port("output_image")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -535,6 +542,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_output_port("output_image")

@required("OpenCV") # pyright: ignore
@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -621,6 +629,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("sources")
self.add_output_port("output_metadata")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -682,6 +691,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("file_path")
self.add_output_port("exif_tags")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -718,6 +728,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("dng_file_path")
self.add_output_port("metadata")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -761,6 +772,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("bypass", False)
self.add_output_port("input_transform", InputTransform())

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -884,6 +896,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("bypass", False)
self.add_output_port("input_transform", InputTransform())

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -988,6 +1001,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_output_port("image")

@required("rawpy") # pyright: ignore
@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1060,6 +1074,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_output_port("output_image")

@required("lensfunpy", "OpenCV") # pyright: ignore
@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1227,6 +1242,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("bypass", False)
self.add_output_port("output_image")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1272,6 +1288,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("bypass", False)
self.add_output_port("output_image")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1331,6 +1348,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("bypass", False)
self.add_output_port("output_image")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1382,6 +1400,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("batch_size", 3)
self.add_output_port("batches", [])

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1415,6 +1434,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("cctf_decoding", linear_function)
self.add_output_port("image_stack")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1458,6 +1478,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("weighting_function", double_sigmoid_anchored_function)
self.add_output_port("image")

@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1504,6 +1525,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.add_input_port("bypass", False)

@required("OpenImageIO")
@notify_process_state
def process(self, **kwargs: Any) -> None: # noqa: ARG002
"""
Process the node.
Expand Down Expand Up @@ -1532,7 +1554,7 @@ def process(self, **kwargs: Any) -> None: # noqa: ARG002
self.log(f"Normalisation factor: {normalisation_factor}")

for image_path in image_paths:
image, attributes = read_image_OpenImageIO(image_path, attributes=True)
image, attributes = read_image_OpenImageIO(image_path, additional_data=True)

image *= normalisation_factor
image *= self.get_input("scaling_factor")
Expand Down
Loading

0 comments on commit d47d768

Please sign in to comment.