Spaces:
Sleeping
Sleeping
Update app.py
Browse files[fix] manual mix
app.py
CHANGED
|
@@ -33,7 +33,11 @@ def generate_mask(img, coord):
|
|
| 33 |
|
| 34 |
#
|
| 35 |
mask = sepia((img*0.999999).astype(np.uint8),(img*0.999999).astype(np.uint8),(img*0.999999).astype(np.uint8),(img*0.999999).astype(np.uint8),(img*0.999999).astype(np.uint8), stack_image=False)
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def overlay_mask(img, mask):
|
| 39 |
# 前置校验(参考网页1数据验证方案)
|
|
|
|
| 33 |
|
| 34 |
#
|
| 35 |
mask = sepia((img*0.999999).astype(np.uint8),(img*0.999999).astype(np.uint8),(img*0.999999).astype(np.uint8),(img*0.999999).astype(np.uint8),(img*0.999999).astype(np.uint8), stack_image=False)
|
| 36 |
+
col = torch.from_numpy(mask).squeeze()
|
| 37 |
+
mask_torch=torch.from_numpy(mask).squeeze()/mask_torch.max()
|
| 38 |
+
col[:,:,0]=0
|
| 39 |
+
mix = (1-mask_torch)*img+mask_torch*img*0.7+mask_torch*col*0.3
|
| 40 |
+
return mix.numpy().astype(np.uint8)#overlay_mask(img, mask)
|
| 41 |
|
| 42 |
def overlay_mask(img, mask):
|
| 43 |
# 前置校验(参考网页1数据验证方案)
|