Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import cv2
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
st.title("Segmentation and Blur Effects")
|
7 |
+
|
8 |
+
uploaded_image = st.file_uploader("Upload an Image", type=["png", "jpg"])
|
9 |
+
uploaded_depth = st.file_uploader("Upload a Depth Map", type=["png", "jpg"])
|
10 |
+
|
11 |
+
if uploaded_image and uploaded_depth:
|
12 |
+
image = Image.open(uploaded_image)
|
13 |
+
depth_map = Image.open(uploaded_depth)
|
14 |
+
|
15 |
+
# Gaussian Blur
|
16 |
+
sigma = st.slider("Gaussian Blur Intensity", 5, 50, 15)
|
17 |
+
blurred_image = cv2.GaussianBlur(np.array(image), (0, 0), sigma)
|
18 |
+
|
19 |
+
# Depth-based Blur (Dummy example)
|
20 |
+
depth_array = np.array(depth_map).astype(np.float32)
|
21 |
+
depth_array = cv2.normalize(depth_array, None, 0, sigma, cv2.NORM_MINMAX)
|
22 |
+
blurred_depth = cv2.GaussianBlur(np.array(image), (0, 0), int(np.max(depth_array)))
|
23 |
+
|
24 |
+
st.image(blurred_image, caption="Gaussian Blur", use_column_width=True)
|
25 |
+
st.image(blurred_depth, caption="Depth-based Blur", use_column_width=True)
|