Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ import re
|
|
| 14 |
def rgba_to_rgb(rgba_string):
|
| 15 |
match = re.match(r'rgba\(([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\)', rgba_string)
|
| 16 |
if not match:
|
| 17 |
-
raise ValueError("
|
| 18 |
|
| 19 |
r, g, b, a = map(float, match.groups())
|
| 20 |
|
|
@@ -180,7 +180,7 @@ filter_functions = {
|
|
| 180 |
# Main function to apply selected filters
|
| 181 |
def apply_filters(image, filter_type, brightness, contrast, sharpening, kernel_size, hue_shift, size, sigma, vignette_strength, vignette_aspect_ratio, vignette_center_x, vignette_center_y, vignette_radius, vignette_smoothness, tint_color, tint_intensity):
|
| 182 |
if image is None:
|
| 183 |
-
|
| 184 |
return None # Return None if the input image is empty
|
| 185 |
|
| 186 |
# Adjust brightness and contrast
|
|
@@ -196,9 +196,7 @@ def apply_filters(image, filter_type, brightness, contrast, sharpening, kernel_s
|
|
| 196 |
tint_color_rgb = (255, 0, 0) # Default color red
|
| 197 |
elif tint_color.startswith('rgba('):
|
| 198 |
try:
|
| 199 |
-
print(tint_color, type(tint_color))
|
| 200 |
tint_color_rgb = rgba_to_rgb(tint_color)
|
| 201 |
-
print(tint_color_rgb)
|
| 202 |
except ValueError:
|
| 203 |
print("Invalid rgba format. Using default color #FF0000.", )
|
| 204 |
tint_color_rgb = (255, 0, 0) # Default color red
|
|
|
|
| 14 |
def rgba_to_rgb(rgba_string):
|
| 15 |
match = re.match(r'rgba\(([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\)', rgba_string)
|
| 16 |
if not match:
|
| 17 |
+
raise ValueError("Invalid RGBA")
|
| 18 |
|
| 19 |
r, g, b, a = map(float, match.groups())
|
| 20 |
|
|
|
|
| 180 |
# Main function to apply selected filters
|
| 181 |
def apply_filters(image, filter_type, brightness, contrast, sharpening, kernel_size, hue_shift, size, sigma, vignette_strength, vignette_aspect_ratio, vignette_center_x, vignette_center_y, vignette_radius, vignette_smoothness, tint_color, tint_intensity):
|
| 182 |
if image is None:
|
| 183 |
+
gr.Error("Input image is empty!") # for debugging
|
| 184 |
return None # Return None if the input image is empty
|
| 185 |
|
| 186 |
# Adjust brightness and contrast
|
|
|
|
| 196 |
tint_color_rgb = (255, 0, 0) # Default color red
|
| 197 |
elif tint_color.startswith('rgba('):
|
| 198 |
try:
|
|
|
|
| 199 |
tint_color_rgb = rgba_to_rgb(tint_color)
|
|
|
|
| 200 |
except ValueError:
|
| 201 |
print("Invalid rgba format. Using default color #FF0000.", )
|
| 202 |
tint_color_rgb = (255, 0, 0) # Default color red
|