File size: 3,980 Bytes
fefa3b2 2065b28 fefa3b2 433afc4 fefa3b2 433afc4 fefa3b2 2065b28 fefa3b2 8bc8354 a41c4bd 8bc8354 a752fbc 8bc8354 fefa3b2 2065b28 fefa3b2 8bc8354 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | import gradio as gr
from yellow_tint_cleaner import auto_adjust
from PIL import Image
import numpy as np
def process_image(
image,
strength,
brightness,
contrast,
saturation,
red,
green,
blue,
mode
):
"""Process the image with the given parameters."""
if image is None:
return None
# Convert the image to PIL Image if it's not already
if not isinstance(image, Image.Image):
image = Image.fromarray(image)
# Process the image
result = auto_adjust(
image,
strength=strength,
brightness=brightness,
contrast=contrast,
saturation=saturation,
red=red,
green=green,
blue=blue,
mode=mode
)
return result
# Create the Gradio interface
with gr.Blocks(title="Yellow Tint Cleaner") as demo:
gr.Markdown("""
# GPT-4o Yellow Tint Cleaner
This app helps you clean yellow tints from your images using various adjustment parameters.
Code adapted from [ComfyUI_LayerStyle](https://github.com/chflame163/ComfyUI_LayerStyle) by chflame163
""")
with gr.Row():
with gr.Column():
input_image = gr.Image(label="Input Image", type="pil", height=600)
with gr.Accordion("Adjustments", open=False):
with gr.Row():
strength = gr.Slider(
minimum=0,
maximum=100,
value=75,
step=1,
label="Strength"
)
brightness = gr.Slider(
minimum=-100,
maximum=100,
value=0,
step=1,
label="Brightness"
)
with gr.Row():
contrast = gr.Slider(
minimum=-100,
maximum=100,
value=0,
step=1,
label="Contrast"
)
saturation = gr.Slider(
minimum=-100,
maximum=100,
value=0,
step=1,
label="Saturation"
)
with gr.Row():
red = gr.Slider(
minimum=-100,
maximum=100,
value=0,
step=1,
label="Red Channel"
)
green = gr.Slider(
minimum=-100,
maximum=100,
value=0,
step=1,
label="Green Channel"
)
with gr.Row():
blue = gr.Slider(
minimum=-100,
maximum=100,
value=0,
step=1,
label="Blue Channel"
)
mode = gr.Dropdown(
choices=["RGB", "lum + sat", "luminance", "saturation", "mono"],
value="lum + sat",
label="Processing Mode"
)
process_btn = gr.Button("Process Image")
with gr.Column():
output_image = gr.Image(label="Output Image", height=600)
process_btn.click(
fn=process_image,
inputs=[
input_image,
strength,
brightness,
contrast,
saturation,
red,
green,
blue,
mode
],
outputs=output_image
)
if __name__ == "__main__":
demo.launch() |