Spaces:
Running
Running
drmurataltun
commited on
Commit
•
442642d
1
Parent(s):
2b764c0
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ def apply_gaussian_blur(frame):
|
|
7 |
return cv2.GaussianBlur(frame, (15, 15), 0)
|
8 |
|
9 |
def apply_sharpening_filter(frame):
|
10 |
-
kernel = np.array([[0, -1, 0], [-1, 5
|
11 |
return cv2.filter2D(frame, -1, kernel)
|
12 |
|
13 |
def apply_edge_detection(frame):
|
@@ -22,6 +22,18 @@ def adjust_brightness_contrast(frame, alpha=1.0, beta=50):
|
|
22 |
def apply_grayscale_filter(frame):
|
23 |
return cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# Filtre uygulama fonksiyonu
|
26 |
def apply_filter(filter_type, input_image=None):
|
27 |
if input_image is not None:
|
@@ -45,6 +57,10 @@ def apply_filter(filter_type, input_image=None):
|
|
45 |
return adjust_brightness_contrast(frame, alpha=1.0, beta=50)
|
46 |
elif filter_type == "Grayscale":
|
47 |
return apply_grayscale_filter(frame)
|
|
|
|
|
|
|
|
|
48 |
|
49 |
# Gradio arayüzü
|
50 |
with gr.Blocks() as demo:
|
@@ -53,10 +69,10 @@ with gr.Blocks() as demo:
|
|
53 |
# Filtre seçenekleri
|
54 |
filter_type = gr.Dropdown(
|
55 |
label="Filtre Seçin",
|
56 |
-
choices=["Gaussian Blur", "Sharpen", "Edge Detection", "Invert", "Brightness", "Grayscale"],
|
57 |
value="Gaussian Blur"
|
58 |
)
|
59 |
-
|
60 |
# Görüntü yükleme alanı
|
61 |
input_image = gr.Image(label="Resim Yükle", type="numpy")
|
62 |
|
|
|
7 |
return cv2.GaussianBlur(frame, (15, 15), 0)
|
8 |
|
9 |
def apply_sharpening_filter(frame):
|
10 |
+
kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]])
|
11 |
return cv2.filter2D(frame, -1, kernel)
|
12 |
|
13 |
def apply_edge_detection(frame):
|
|
|
22 |
def apply_grayscale_filter(frame):
|
23 |
return cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
24 |
|
25 |
+
def apply_sepia_filter(frame):
|
26 |
+
sepia_filter = np.array([[0.272, 0.534, 0.131],
|
27 |
+
[0.349, 0.686, 0.168],
|
28 |
+
[0.393, 0.769, 0.189]])
|
29 |
+
return cv2.transform(frame, sepia_filter)
|
30 |
+
|
31 |
+
def apply_fall_filter(frame):
|
32 |
+
fall_filter = np.array([[0.393, 0.769, 0.189],
|
33 |
+
[0.349, 0.686, 0.168],
|
34 |
+
[0.272, 0.534, 0.131]])
|
35 |
+
return cv2.transform(frame, fall_filter)
|
36 |
+
|
37 |
# Filtre uygulama fonksiyonu
|
38 |
def apply_filter(filter_type, input_image=None):
|
39 |
if input_image is not None:
|
|
|
57 |
return adjust_brightness_contrast(frame, alpha=1.0, beta=50)
|
58 |
elif filter_type == "Grayscale":
|
59 |
return apply_grayscale_filter(frame)
|
60 |
+
elif filter_type == "Sepia":
|
61 |
+
return apply_sepia_filter(frame)
|
62 |
+
elif filter_type == "Sonbahar":
|
63 |
+
return apply_fall_filter(frame)
|
64 |
|
65 |
# Gradio arayüzü
|
66 |
with gr.Blocks() as demo:
|
|
|
69 |
# Filtre seçenekleri
|
70 |
filter_type = gr.Dropdown(
|
71 |
label="Filtre Seçin",
|
72 |
+
choices=["Gaussian Blur", "Sharpen", "Edge Detection", "Invert", "Brightness", "Grayscale", "Sepia", "Sonbahar"],
|
73 |
value="Gaussian Blur"
|
74 |
)
|
75 |
+
|
76 |
# Görüntü yükleme alanı
|
77 |
input_image = gr.Image(label="Resim Yükle", type="numpy")
|
78 |
|