nsathya5 commited on
Commit
df258b2
·
verified ·
1 Parent(s): 2885205

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -43,7 +43,6 @@ def segment_image(image):
43
  original_size = image.size
44
 
45
  # Use higher resolution for better results while staying within model limits
46
- # Most models work well with 640x640
47
  model_size = (640, 640)
48
  model_image = image.resize(model_size, Image.LANCZOS)
49
 
@@ -87,9 +86,12 @@ def segment_image(image):
87
  # Convert back to numpy
88
  mask_array = np.array(mask_resized) > 128
89
 
90
- # Create visualization of mask (red on black background)
91
  mask_viz = np.zeros((mask_array.shape[0], mask_array.shape[1], 3), dtype=np.uint8)
 
92
  mask_viz[:,:,0] = mask_array * 255 # Red channel
 
 
93
 
94
  return mask_array, mask_viz
95
 
@@ -313,7 +315,7 @@ with gr.Blocks(title="Image Blur Effects") as demo:
313
  gr.Markdown("4. Click 'Apply Effect'")
314
  gr.Markdown("")
315
  gr.Markdown("### Notes")
316
- gr.Markdown("- The red areas in the Foreground Mask show what will remain sharp")
317
  gr.Markdown("- The Depth Map shows estimated distances (yellow=far, blue=close)")
318
  gr.Markdown("- Gaussian Blur applies uniform blur to the background")
319
  gr.Markdown("- Depth-based Blur varies blur intensity based on distance")
 
43
  original_size = image.size
44
 
45
  # Use higher resolution for better results while staying within model limits
 
46
  model_size = (640, 640)
47
  model_image = image.resize(model_size, Image.LANCZOS)
48
 
 
86
  # Convert back to numpy
87
  mask_array = np.array(mask_resized) > 128
88
 
89
+ # Create visualization of mask (white on black background)
90
  mask_viz = np.zeros((mask_array.shape[0], mask_array.shape[1], 3), dtype=np.uint8)
91
+ # Set all channels to the same value to create white
92
  mask_viz[:,:,0] = mask_array * 255 # Red channel
93
+ mask_viz[:,:,1] = mask_array * 255 # Green channel
94
+ mask_viz[:,:,2] = mask_array * 255 # Blue channel
95
 
96
  return mask_array, mask_viz
97
 
 
315
  gr.Markdown("4. Click 'Apply Effect'")
316
  gr.Markdown("")
317
  gr.Markdown("### Notes")
318
+ gr.Markdown("- The white areas in the Foreground Mask show what will remain sharp")
319
  gr.Markdown("- The Depth Map shows estimated distances (yellow=far, blue=close)")
320
  gr.Markdown("- Gaussian Blur applies uniform blur to the background")
321
  gr.Markdown("- Depth-based Blur varies blur intensity based on distance")