BraUndress commited on
Commit
03a1944
·
verified ·
1 Parent(s): 58b441d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -212,7 +212,15 @@ def dummy(img):
212
  alpha_channel = img["layers"][0][:, :, 3]
213
  mask = np.where(alpha_channel == 0, 0, 255).astype(np.uint8)
214
 
215
- return mask
 
 
 
 
 
 
 
 
216
 
217
 
218
  # Function to update the image in Tab 1
 
212
  alpha_channel = img["layers"][0][:, :, 3]
213
  mask = np.where(alpha_channel == 0, 0, 255).astype(np.uint8)
214
 
215
+ # 将蒙版转换为与原始图像相同分辨率的图像
216
+ mask_image_pil = Image.fromarray(mask)
217
+ mask_image_resized = mask_image_pil.resize((composite_width, composite_height), Image.ANTIALIAS)
218
+
219
+ # 将调整大小后的蒙版图像转换回 numpy 数组
220
+ mask_resized = np.array(mask_image_resized)
221
+
222
+ return mask_resized
223
+
224
 
225
 
226
  # Function to update the image in Tab 1