Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -128,18 +128,18 @@ def inference(image: Image):
|
|
| 128 |
image_tensor, orig_size = load_image(image_path, hypar)
|
| 129 |
mask = predict(net, image_tensor, orig_size, hypar, device)
|
| 130 |
|
| 131 |
-
|
| 132 |
-
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
image = (image_tensor.detach().cpu().numpy()*255).astype(np.uint8)
|
| 140 |
-
mask = (mask*255).astype(np.uint8)
|
| 141 |
|
| 142 |
-
return image, mask
|
| 143 |
|
| 144 |
title = "智能抠图"
|
| 145 |
description = "可以从给定图像中删除背景的模型。 要使用它,只需上传您的图像<br>右键图片另存为,下载图片"
|
|
|
|
| 128 |
image_tensor, orig_size = load_image(image_path, hypar)
|
| 129 |
mask = predict(net, image_tensor, orig_size, hypar, device)
|
| 130 |
|
| 131 |
+
pil_mask = Image.fromarray(mask).convert("L")
|
| 132 |
+
im_rgb = Image.open(image).convert("RGB")
|
| 133 |
|
| 134 |
+
im_rgba = im_rgb.copy()
|
| 135 |
+
im_rgba.putalpha(pil_mask)
|
| 136 |
|
| 137 |
+
return [im_rgba, pil_mask]
|
| 138 |
|
| 139 |
+
#image = (image_tensor.detach().cpu().numpy()*255).astype(np.uint8)
|
| 140 |
+
#mask = (mask*255).astype(np.uint8)
|
| 141 |
|
| 142 |
+
#return image, mask
|
| 143 |
|
| 144 |
title = "智能抠图"
|
| 145 |
description = "可以从给定图像中删除背景的模型。 要使用它,只需上传您的图像<br>右键图片另存为,下载图片"
|