Update app.py
Browse files
app.py
CHANGED
@@ -79,12 +79,13 @@ def depth_based_lens_blur(input_image: Image.Image, max_blur: float = 2, num_ban
|
|
79 |
"""
|
80 |
Applies a depth-based blur effect using a depth map from Depth-Anything.
|
81 |
The blur intensity is controlled by the max_blur parameter.
|
|
|
82 |
"""
|
83 |
-
#
|
84 |
-
|
85 |
|
86 |
# Obtain the depth map using the depth estimation pipeline
|
87 |
-
results = depth_pipeline(
|
88 |
depth_map_image = results['depth']
|
89 |
|
90 |
# Normalize the depth map to [0, 1]
|
@@ -94,8 +95,8 @@ def depth_based_lens_blur(input_image: Image.Image, max_blur: float = 2, num_ban
|
|
94 |
if invert_depth:
|
95 |
depth_norm = 1.0 - depth_norm
|
96 |
|
97 |
-
# Convert the
|
98 |
-
orig_rgba =
|
99 |
final_image = orig_rgba.copy()
|
100 |
|
101 |
# Divide the depth range into bands and apply variable blur
|
@@ -143,7 +144,7 @@ iface = gr.Interface(
|
|
143 |
title="EEE 515: Interactive Blur Effects Demo - by: Krishna Vinod",
|
144 |
description=(
|
145 |
"How to use this App: Upload an image and choose an effect. For 'Gaussian Blur Background', adjust the segmentation threshold and blur intensity. "
|
146 |
-
"For 'Depth-based Lens Blur', the blur intensity slider sets the maximum blur based on depth. Use the camera interface for more
|
147 |
)
|
148 |
)
|
149 |
|
|
|
79 |
"""
|
80 |
Applies a depth-based blur effect using a depth map from Depth-Anything.
|
81 |
The blur intensity is controlled by the max_blur parameter.
|
82 |
+
NOTE: This function now uses the original image size without resizing.
|
83 |
"""
|
84 |
+
# Use the original image for depth estimation (no resizing)
|
85 |
+
image_for_depth = input_image.convert("RGB")
|
86 |
|
87 |
# Obtain the depth map using the depth estimation pipeline
|
88 |
+
results = depth_pipeline(image_for_depth)
|
89 |
depth_map_image = results['depth']
|
90 |
|
91 |
# Normalize the depth map to [0, 1]
|
|
|
95 |
if invert_depth:
|
96 |
depth_norm = 1.0 - depth_norm
|
97 |
|
98 |
+
# Convert the original image to RGBA for proper compositing
|
99 |
+
orig_rgba = image_for_depth.convert("RGBA")
|
100 |
final_image = orig_rgba.copy()
|
101 |
|
102 |
# Divide the depth range into bands and apply variable blur
|
|
|
144 |
title="EEE 515: Interactive Blur Effects Demo - by: Krishna Vinod",
|
145 |
description=(
|
146 |
"How to use this App: Upload an image and choose an effect. For 'Gaussian Blur Background', adjust the segmentation threshold and blur intensity. "
|
147 |
+
"For 'Depth-based Lens Blur', the blur intensity slider sets the maximum blur based on depth. Use the camera interface for a more interactive experience ;)"
|
148 |
)
|
149 |
)
|
150 |
|