narain commited on
Commit
634fed0
·
1 Parent(s): 6d9557a

update code

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -20,7 +20,7 @@ depth_model = AutoModelForDepthEstimation.from_pretrained("depth-anything/Depth-
20
 
21
  def apply_blur(image, blur_type, blur_strength):
22
  # Convert image to RGB
23
- img = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
24
 
25
  if blur_type == "Gaussian":
26
  # Use Segformer for Gaussian blur
@@ -31,6 +31,7 @@ def apply_blur(image, blur_type, blur_strength):
31
 
32
  mask = logits[0, 12, :, :].detach().cpu().numpy() > -4
33
  mask = cv2.resize(mask.astype(np.uint8), (img.shape[1], img.shape[0]))
 
34
 
35
  elif blur_type == "Lens":
36
  # Use Depth-Anything for lens blur
@@ -51,8 +52,6 @@ def apply_blur(image, blur_type, blur_strength):
51
  mask = prediction[0, 0, :, :].detach().cpu().numpy() < 3
52
  mask = mask.astype(np.uint8)
53
 
54
- # Invert mask using cv2
55
- mask = cv2.bitwise_not(mask)
56
  mask = np.repeat(mask[:, :, np.newaxis], 3, axis=2)
57
 
58
  # Apply blur based on selected type
 
20
 
21
  def apply_blur(image, blur_type, blur_strength):
22
  # Convert image to RGB
23
+ img = cv2.cvtColor(image)
24
 
25
  if blur_type == "Gaussian":
26
  # Use Segformer for Gaussian blur
 
31
 
32
  mask = logits[0, 12, :, :].detach().cpu().numpy() > -4
33
  mask = cv2.resize(mask.astype(np.uint8), (img.shape[1], img.shape[0]))
34
+ mask = cv2.bitwise_not(mask)
35
 
36
  elif blur_type == "Lens":
37
  # Use Depth-Anything for lens blur
 
52
  mask = prediction[0, 0, :, :].detach().cpu().numpy() < 3
53
  mask = mask.astype(np.uint8)
54
 
 
 
55
  mask = np.repeat(mask[:, :, np.newaxis], 3, axis=2)
56
 
57
  # Apply blur based on selected type