Add ComfyUI support
my bad y'all
This commit is contained in:
parent
b9e4a2cfa1
commit
78a01e432e
5 changed files with 59 additions and 16 deletions
|
@ -1,14 +1,8 @@
|
|||
import gradio as gr
|
||||
import imageio.core.util
|
||||
import numpy as np
|
||||
import skimage.color
|
||||
from PIL import Image
|
||||
|
||||
from modules import scripts_postprocessing
|
||||
from modules.ui_components import FormRow
|
||||
|
||||
|
||||
imageio.core.util._precision_warn = lambda *args, **kwargs: None
|
||||
import mmaker_color_enhance_core as lib
|
||||
|
||||
|
||||
class ScriptPostprocessingColorEnhance(scripts_postprocessing.ScriptPostprocessing):
|
||||
|
@ -25,14 +19,8 @@ class ScriptPostprocessingColorEnhance(scripts_postprocessing.ScriptPostprocessi
|
|||
return
|
||||
|
||||
info_bak = {} if not hasattr(pp.image, "info") else pp.image.info
|
||||
pp.image = self._color_enhance(pp.image, strength)
|
||||
pp.image = lib.color_enhance(pp.image, strength)
|
||||
pp.image.info = info_bak
|
||||
pp.info["Color Enhance"] = strength
|
||||
|
||||
def _lerp(self, a: float, b: float, t: float) -> float:
|
||||
return (1 - t) * a + t * b
|
||||
|
||||
def _color_enhance(self, arr, strength: float = 1) -> Image.Image:
|
||||
lch = skimage.color.lab2lch(lab=skimage.color.rgb2lab(rgb=np.array(arr, dtype=np.uint8)))
|
||||
lch[:, :, 1] *= 100/(self._lerp(100, lch[:, :, 1].max(), strength)) # Normalize chroma component
|
||||
return Image.fromarray(np.array(skimage.color.lab2rgb(lab=skimage.color.lch2lab(lch=lch)) * 255, dtype=np.uint8))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue