Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -38,6 +38,7 @@ theme = gr.themes.Soft(
|
|
38 |
)
|
39 |
#----------End of theme----------
|
40 |
|
|
|
41 |
def flip_image(x):
|
42 |
return np.fliplr(x)
|
43 |
|
@@ -63,7 +64,7 @@ def basic_filter(image, filter_type):
|
|
63 |
kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
|
64 |
sharpened = cv2.filter2D(enhanced, -1, kernel)
|
65 |
return cv2.cvtColor(sharpened, cv2.COLOR_GRAY2BGR)
|
66 |
-
elif filter_type == "
|
67 |
return cv2.GaussianBlur(image, (15, 15), 0)
|
68 |
|
69 |
def classic_filter(image, filter_type):
|
@@ -91,18 +92,7 @@ def classic_filter(image, filter_type):
|
|
91 |
|
92 |
def creative_filter(image, filter_type):
|
93 |
"""Creative and unusual image filters"""
|
94 |
-
if filter_type == "
|
95 |
-
h, w = image.shape[:2]
|
96 |
-
mosaic_size = 30
|
97 |
-
for i in range(0, h, mosaic_size):
|
98 |
-
for j in range(0, w, mosaic_size):
|
99 |
-
roi = image[i:i+mosaic_size, j:j+mosaic_size]
|
100 |
-
if roi.size > 0:
|
101 |
-
color = np.mean(roi, axis=(0,1))
|
102 |
-
image[i:i+mosaic_size, j:j+mosaic_size] = color
|
103 |
-
return image
|
104 |
-
|
105 |
-
elif filter_type == "Rainbow":
|
106 |
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
107 |
h, w = image.shape[:2]
|
108 |
for i in range(h):
|
@@ -243,7 +233,7 @@ def image_processing(image, filter_type):
|
|
243 |
# Process by filter categories
|
244 |
basic_filter_list = ["Grey Toning", "Sepia", "X-ray", "Blur"]
|
245 |
Classic_filters_list = ["Charcoal Effect", "Sharpen", "Relief", "Edge Detection"]
|
246 |
-
creative_filters_list = ["
|
247 |
special_effects_list = ["Matrix Effect", "Wave Effect", "Time Stamp," "Glitch Effect"]
|
248 |
artistic_filters_listesi = ["Pop Art", "Oil Paint", "Cartoon"]
|
249 |
atmospheric_filters_list = ["Autumn", "Nostalgia", "Increase Brightness"]
|
@@ -287,7 +277,7 @@ with gr.Blocks(theme=theme) as app:
|
|
287 |
# Classic_filters_list
|
288 |
"Charcoal Effect", "Sharpen", "Relief", "Edge Detection",
|
289 |
# Creative Filters
|
290 |
-
"
|
291 |
# Special Effects
|
292 |
"Matrix Effect", "Wave Effect", "Time Stamp", "Glitch Effect",
|
293 |
# Artistic Filters
|
|
|
38 |
)
|
39 |
#----------End of theme----------
|
40 |
|
41 |
+
|
42 |
def flip_image(x):
|
43 |
return np.fliplr(x)
|
44 |
|
|
|
64 |
kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]])
|
65 |
sharpened = cv2.filter2D(enhanced, -1, kernel)
|
66 |
return cv2.cvtColor(sharpened, cv2.COLOR_GRAY2BGR)
|
67 |
+
elif filter_type == "Burn it":
|
68 |
return cv2.GaussianBlur(image, (15, 15), 0)
|
69 |
|
70 |
def classic_filter(image, filter_type):
|
|
|
92 |
|
93 |
def creative_filter(image, filter_type):
|
94 |
"""Creative and unusual image filters"""
|
95 |
+
if filter_type == "Rainbow":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
97 |
h, w = image.shape[:2]
|
98 |
for i in range(h):
|
|
|
233 |
# Process by filter categories
|
234 |
basic_filter_list = ["Grey Toning", "Sepia", "X-ray", "Blur"]
|
235 |
Classic_filters_list = ["Charcoal Effect", "Sharpen", "Relief", "Edge Detection"]
|
236 |
+
creative_filters_list = ["Rainbow", "Night Vision"]
|
237 |
special_effects_list = ["Matrix Effect", "Wave Effect", "Time Stamp," "Glitch Effect"]
|
238 |
artistic_filters_listesi = ["Pop Art", "Oil Paint", "Cartoon"]
|
239 |
atmospheric_filters_list = ["Autumn", "Nostalgia", "Increase Brightness"]
|
|
|
277 |
# Classic_filters_list
|
278 |
"Charcoal Effect", "Sharpen", "Relief", "Edge Detection",
|
279 |
# Creative Filters
|
280 |
+
"Rainbow", "Night Vision",
|
281 |
# Special Effects
|
282 |
"Matrix Effect", "Wave Effect", "Time Stamp", "Glitch Effect",
|
283 |
# Artistic Filters
|