Skip to content

Commit bad7182

Browse files
authored
Load LUT once (#17)
1 parent 3e864cd commit bad7182

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

nodes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,25 +431,25 @@ def lut_image(self, image: torch.Tensor, lut_name, strength: float, log: bool):
431431
batch_size, height, width, _ = image.shape
432432
result = torch.zeros_like(image)
433433

434+
# Read the LUT
435+
lut_path = os.path.join(dir_luts, lut_name)
436+
lut = loading_utils.read_lut(lut_path, clip=True)
437+
434438
for b in range(batch_size):
435439
tensor_image = image[b].numpy()
436440

437441
# Apply LUT
438-
lut_image = self.apply_lut(tensor_image, lut_name, strength, log)
442+
lut_image = self.apply_lut(tensor_image, lut, strength, log)
439443

440444
tensor = torch.from_numpy(lut_image).unsqueeze(0)
441445
result[b] = tensor
442446

443447
return (result,)
444448

445-
def apply_lut(self, image, lut_name, strength, log):
449+
def apply_lut(self, image, lut, strength, log):
446450
if strength == 0:
447451
return image
448452

449-
# Read the LUT
450-
lut_path = os.path.join(dir_luts, lut_name)
451-
lut = loading_utils.read_lut(lut_path, clip=True)
452-
453453
# Apply the LUT
454454
is_non_default_domain = not np.array_equal(lut.domain, np.array([[0., 0., 0.], [1., 1., 1.]]))
455455
dom_scale = None

0 commit comments

Comments
 (0)