Some algorithms I share
- modified from sd-webui-stablesr colorfix
- supports cpu, cuda(fp16/fp32)
import numpy as np
import torch
from torch import Tensor
from color_correction import ColorCorrection
in_tensor: Tensor
ref_tensor: Tensor
color_correction = ColorCorrection()
color_correction = color_correction.to(device=device)
with torch.inference_mode():
d_out: Tensor = color_correction(in_tensor, ref_tensor)
d_out = torch.clamp(d_out, 0., 1.)