JustSkyDev commited on
Commit
e7cf17b
·
1 Parent(s): 2a9c2a8

Update process.py

Browse files
Files changed (1) hide show
  1. process.py +4 -7
process.py CHANGED
@@ -24,12 +24,9 @@ def Segment(image: Image.Image):
24
  mask = (prediction > 0).cpu().numpy()
25
  mask = np.where(mask==1, 255, 0).astype(np.uint8)
26
  mask = unpad(mask, pads)
27
-
28
- alpha_channel = np.ones(mask.shape, dtype=np.uint8) * 255
29
- alpha_channel[mask == 0] = 0
30
-
31
- image_with_alpha = cv2.cvtColor(image, cv2.COLOR_RGB2RGBA)
32
- image_with_alpha[:, :, 3] = alpha_channel
33
- output_image = Image.fromarray(image_with_alpha)
34
 
35
  return output_image
 
24
  mask = (prediction > 0).cpu().numpy()
25
  mask = np.where(mask==1, 255, 0).astype(np.uint8)
26
  mask = unpad(mask, pads)
27
+
28
+ output_image = np.zeros((*mask.shape, 4), dtype=np.uint8)
29
+ output_image[mask == 255] = [255, 255, 255, 255]
30
+ output_image = Image.fromarray(output_image, 'RGBA')
 
 
 
31
 
32
  return output_image