LUT application strength
This commit is contained in:
@@ -225,16 +225,23 @@ class VCGApplyLUT(IO.ComfyNode):
|
||||
return IO.Schema(
|
||||
node_id="VCGApplyLUT", display_name="Apply 3D LUT (VCG)", category="video/color-grading",
|
||||
description="Apply a generated 3D color LUT to images",
|
||||
inputs=[IO.Image.Input("images"), VCG_LUT.Input("lut")],
|
||||
inputs=[
|
||||
IO.Image.Input("images"),
|
||||
VCG_LUT.Input("lut"),
|
||||
IO.Float.Input("strength", default=1.0, min=0.0, max=2.0, step=0.01, optional=True, tooltip="LUT strength: 0=no effect, 1=full effect, >1=exaggerated"),
|
||||
],
|
||||
outputs=[IO.Image.Output()],
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def execute(cls, images, lut):
|
||||
def execute(cls, images, lut, strength=1.0):
|
||||
device = comfy.model_management.intermediate_device()
|
||||
dtype = images.dtype
|
||||
lut_3d = torch.from_numpy(lut["values"].reshape(16, 16, 16, 3).astype(np.float32))
|
||||
if strength != 1.0:
|
||||
identity = torch.from_numpy(make_identity_lut(16).reshape(16, 16, 16, 3).astype(np.float32))
|
||||
lut_3d = identity + strength * (lut_3d - identity)
|
||||
lut_vol = lut_3d.permute(3, 0, 1, 2).unsqueeze(0).to(device=device, dtype=dtype)
|
||||
B = images.shape[0]
|
||||
output = torch.empty_like(images)
|
||||
|
||||
Reference in New Issue
Block a user