Saitama0510 commited on
Commit
f15e528
·
verified ·
1 Parent(s): 745f2bf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image, ImageFilter
3
+
4
+ def main():
5
+ st.title("Custom Background Blur Demo")
6
+
7
+ # 1. Upload an image
8
+ uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
9
+
10
+ if uploaded_file is not None:
11
+ # 2. Open and display the original image
12
+ image = Image.open(uploaded_file).convert("RGB")
13
+ st.image(image, caption="Original Image", use_column_width=True)
14
+
15
+ # 3. Choose a blur type
16
+ blur_type = st.selectbox("Select a blur effect", ["Gaussian Blur", "Lens Blur"])
17
+
18
+ if blur_type == "Gaussian Blur":
19
+ # Slider to choose the radius
20
+ blur_radius = st.slider("Gaussian Blur Radius", 0, 30, 5)
21
+ # Apply Gaussian blur
22
+ blurred_image = image.filter(ImageFilter.GaussianBlur(blur_radius))
23
+ # Display result
24
+ st.image(blurred_image, caption=f"Gaussian Blur (radius={blur_radius})", use_column_width=True)
25
+
26
+ elif blur_type == "Lens Blur":
27
+ st.write("Lens blur effect demo (replace this with your own code).")
28
+ # Example: just do a stronger blur to mimic lens blur
29
+ # Replace with your depth-based lens blur or any advanced technique
30
+ lens_blur_radius = st.slider("Lens Blur Intensity", 0, 30, 10)
31
+ lens_blur_image = image.filter(ImageFilter.GaussianBlur(lens_blur_radius))
32
+ st.image(lens_blur_image, caption=f"Lens Blur (radius={lens_blur_radius})", use_column_width=True)
33
+
34
+ if __name__ == "__main__":
35
+ main()