kvinod15 commited on
Commit
aca1feb
·
verified ·
1 Parent(s): af7f17b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
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
- # Resize input image to 512x512 for the depth estimation model
84
- image_resized = input_image.resize((512, 512))
85
 
86
  # Obtain the depth map using the depth estimation pipeline
87
- results = depth_pipeline(image_resized)
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 resized image to RGBA for proper compositing
98
- orig_rgba = image_resized.convert("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 fun interactive experience ;)"
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