Spaces:
Running
Running
Upload 2 files
Browse files- app.py +83 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image, ImageEnhance, ImageFilter, ImageOps
|
3 |
+
import io
|
4 |
+
|
5 |
+
st.title("Gelişmiş Görüntü İşleme Uygulaması")
|
6 |
+
st.write("Yüklediğiniz görsel üzerinde efektleri gerçek zamanlı olarak deneyimleyin!")
|
7 |
+
|
8 |
+
# Kullanıcıdan fotoğraf yüklemesini iste
|
9 |
+
uploaded_file = st.file_uploader("Bir fotoğraf yükleyin", type=["jpg", "jpeg", "png"])
|
10 |
+
|
11 |
+
if uploaded_file:
|
12 |
+
# Yüklenen görüntüyü aç
|
13 |
+
image = Image.open(uploaded_file)
|
14 |
+
|
15 |
+
# Efekt uygulanmış görüntü için kopyasını oluştur
|
16 |
+
edited_image = image.copy()
|
17 |
+
|
18 |
+
# Orijinal ve efektli görüntüleri yan yana göstermek için sütunlar oluştur
|
19 |
+
col1, col2 = st.columns(2)
|
20 |
+
|
21 |
+
with col1:
|
22 |
+
st.header("Orijinal Görüntü")
|
23 |
+
st.image(image, use_column_width=True)
|
24 |
+
|
25 |
+
# Efekt ayarları fotoğrafların altında olacak şekilde düzenlenir
|
26 |
+
st.write("### Efekt Seçenekleri")
|
27 |
+
grayscale = st.checkbox("Gri Ton")
|
28 |
+
blur_intensity = st.slider("Bulanıklık Yoğunluğu", 0, 10, 0)
|
29 |
+
sharpen_intensity = st.slider("Keskinleştirme Yoğunluğu", 0, 10, 0)
|
30 |
+
brightness_intensity = st.slider("Parlaklık", 0.5, 3.0, 1.0)
|
31 |
+
contrast_intensity = st.slider("Kontrast", 0.5, 3.0, 1.0)
|
32 |
+
sepia = st.checkbox("Sepya Efekti")
|
33 |
+
edge_detection = st.checkbox("Kenar Algılama")
|
34 |
+
mirror = st.checkbox("Ayna Yansıması")
|
35 |
+
rotation_angle = st.slider("Döndürme Açısı", 0, 360, 0)
|
36 |
+
|
37 |
+
# Seçimlere göre efektleri uygula
|
38 |
+
if grayscale:
|
39 |
+
edited_image = edited_image.convert("L").convert("RGB")
|
40 |
+
|
41 |
+
if blur_intensity > 0:
|
42 |
+
edited_image = edited_image.filter(ImageFilter.GaussianBlur(blur_intensity))
|
43 |
+
|
44 |
+
if sharpen_intensity > 0:
|
45 |
+
for _ in range(sharpen_intensity):
|
46 |
+
edited_image = edited_image.filter(ImageFilter.SHARPEN)
|
47 |
+
|
48 |
+
if brightness_intensity != 1.0:
|
49 |
+
enhancer = ImageEnhance.Brightness(edited_image)
|
50 |
+
edited_image = enhancer.enhance(brightness_intensity)
|
51 |
+
|
52 |
+
if contrast_intensity != 1.0:
|
53 |
+
enhancer = ImageEnhance.Contrast(edited_image)
|
54 |
+
edited_image = enhancer.enhance(contrast_intensity)
|
55 |
+
|
56 |
+
if sepia:
|
57 |
+
sepia_image = ImageOps.colorize(edited_image.convert("L"), black="black", white="brown")
|
58 |
+
edited_image = sepia_image
|
59 |
+
|
60 |
+
if edge_detection:
|
61 |
+
edited_image = edited_image.filter(ImageFilter.FIND_EDGES)
|
62 |
+
|
63 |
+
if mirror:
|
64 |
+
edited_image = ImageOps.mirror(edited_image)
|
65 |
+
|
66 |
+
if rotation_angle != 0:
|
67 |
+
edited_image = edited_image.rotate(rotation_angle, expand=True)
|
68 |
+
|
69 |
+
# Efekt uygulanmış fotoğrafı sağ sütunda göster
|
70 |
+
with col2:
|
71 |
+
st.header("Efektli Görüntü")
|
72 |
+
st.image(edited_image, use_column_width=True)
|
73 |
+
|
74 |
+
# Görüntüyü indirme butonu
|
75 |
+
buf = io.BytesIO()
|
76 |
+
edited_image.save(buf, format="PNG")
|
77 |
+
byte_im = buf.getvalue()
|
78 |
+
st.download_button(
|
79 |
+
label="Efektli Görüntüyü İndir",
|
80 |
+
data=byte_im,
|
81 |
+
file_name="efektli_goruntu.png",
|
82 |
+
mime="image/png"
|
83 |
+
)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
Pillow
|