Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image, ImageEnhance
|
| 3 |
|
| 4 |
-
def enhance_image(image, vibrancy_factor, sharpness_factor):
|
| 5 |
# Convert to RGB (JPEG doesn't support transparency)
|
| 6 |
image = image.convert("RGB")
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# Vibrancy (color enhancement)
|
| 9 |
image = ImageEnhance.Color(image).enhance(vibrancy_factor)
|
| 10 |
image = ImageEnhance.Brightness(image).enhance(1.0 + (vibrancy_factor-1)*0.2)
|
|
@@ -20,15 +34,16 @@ iface = gr.Interface(
|
|
| 20 |
inputs=[
|
| 21 |
gr.Image(type="pil", label="Original Image (WEBP)"),
|
| 22 |
gr.Slider(0.5, 2.0, 1.0, step=0.1, label="Vibrancy Level"),
|
| 23 |
-
gr.Slider(0.5, 3.0, 1.0, step=0.1, label="Sharpness Level")
|
|
|
|
| 24 |
],
|
| 25 |
outputs=gr.Image(
|
| 26 |
type="pil",
|
| 27 |
label="Enhanced Image (JPEG)",
|
| 28 |
-
format="jpeg"
|
| 29 |
),
|
| 30 |
title="Vibrancy & Sharpness Booster",
|
| 31 |
-
description="Adjust vibrancy and
|
| 32 |
)
|
| 33 |
|
| 34 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image, ImageEnhance
|
| 3 |
|
| 4 |
+
def enhance_image(image, vibrancy_factor, sharpness_factor, blue_yellow_factor):
|
| 5 |
# Convert to RGB (JPEG doesn't support transparency)
|
| 6 |
image = image.convert("RGB")
|
| 7 |
|
| 8 |
+
# Apply blue/yellow color balance
|
| 9 |
+
factor = blue_yellow_factor # -1.0 (yellow) to 1.0 (blue)
|
| 10 |
+
r_scale = 1.0 - factor # Reduce red when adding blue
|
| 11 |
+
g_scale = 1.0 - factor # Reduce green when adding blue
|
| 12 |
+
b_scale = 1.0 + factor # Increase blue
|
| 13 |
+
|
| 14 |
+
# Create color balance matrix
|
| 15 |
+
matrix = (
|
| 16 |
+
r_scale, 0, 0, 0,
|
| 17 |
+
0, g_scale, 0, 0,
|
| 18 |
+
0, 0, b_scale, 0
|
| 19 |
+
)
|
| 20 |
+
image = image.convert("RGB", matrix)
|
| 21 |
+
|
| 22 |
# Vibrancy (color enhancement)
|
| 23 |
image = ImageEnhance.Color(image).enhance(vibrancy_factor)
|
| 24 |
image = ImageEnhance.Brightness(image).enhance(1.0 + (vibrancy_factor-1)*0.2)
|
|
|
|
| 34 |
inputs=[
|
| 35 |
gr.Image(type="pil", label="Original Image (WEBP)"),
|
| 36 |
gr.Slider(0.5, 2.0, 1.0, step=0.1, label="Vibrancy Level"),
|
| 37 |
+
gr.Slider(0.5, 3.0, 1.0, step=0.1, label="Sharpness Level"),
|
| 38 |
+
gr.Slider(-1.0, 1.0, 0.0, step=0.1, label="Blue/Yellow Balance")
|
| 39 |
],
|
| 40 |
outputs=gr.Image(
|
| 41 |
type="pil",
|
| 42 |
label="Enhanced Image (JPEG)",
|
| 43 |
+
format="jpeg"
|
| 44 |
),
|
| 45 |
title="Vibrancy & Sharpness Booster",
|
| 46 |
+
description="Adjust vibrancy, sharpness, and color balance (1.0 = original)"
|
| 47 |
)
|
| 48 |
|
| 49 |
if __name__ == "__main__":
|