Spaces:
Runtime error
Runtime error
Commit ·
dff0630
1
Parent(s): 1f2dc12
add blur to mask and changed mask process
Browse files- .gitignore +2 -1
- processing/mask.py +6 -5
- processing/mask.pyi +3 -1
.gitignore
CHANGED
|
@@ -4,4 +4,5 @@
|
|
| 4 |
IP-Adapter
|
| 5 |
./models
|
| 6 |
./sdxl_models
|
| 7 |
-
DPT/weights
|
|
|
|
|
|
| 4 |
IP-Adapter
|
| 5 |
./models
|
| 6 |
./sdxl_models
|
| 7 |
+
DPT/weights
|
| 8 |
+
.workspace
|
processing/mask.py
CHANGED
|
@@ -1,17 +1,18 @@
|
|
| 1 |
import cv2
|
| 2 |
import numpy as np
|
| 3 |
import torch
|
| 4 |
-
from PIL import Image
|
| 5 |
from rembg import remove
|
| 6 |
from torchvision.transforms import Compose
|
| 7 |
|
| 8 |
from DPT.dpt.transforms import PrepareForNet, NormalizeImage, Resize
|
| 9 |
|
| 10 |
|
| 11 |
-
def create_mask(image):
|
| 12 |
-
rm_bg = remove(image)
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
def create_depth_map(image, model):
|
|
|
|
| 1 |
import cv2
|
| 2 |
import numpy as np
|
| 3 |
import torch
|
| 4 |
+
from PIL import Image, ImageFilter
|
| 5 |
from rembg import remove
|
| 6 |
from torchvision.transforms import Compose
|
| 7 |
|
| 8 |
from DPT.dpt.transforms import PrepareForNet, NormalizeImage, Resize
|
| 9 |
|
| 10 |
|
| 11 |
+
def create_mask(image, blur=True):
|
| 12 |
+
rm_bg = remove(image, post_process_mask=True, only_mask=True)
|
| 13 |
+
if blur:
|
| 14 |
+
rm_bg = rm_bg.filter(ImageFilter.GaussianBlur(3))
|
| 15 |
+
return rm_bg.resize((1024, 1024))
|
| 16 |
|
| 17 |
|
| 18 |
def create_depth_map(image, model):
|
processing/mask.pyi
CHANGED
|
@@ -3,9 +3,11 @@ import torch
|
|
| 3 |
from PIL.Image import Image
|
| 4 |
|
| 5 |
|
| 6 |
-
def create_mask(image: Image) -> Image:
|
| 7 |
"""
|
| 8 |
Create a mask from the input image.
|
|
|
|
|
|
|
| 9 |
"""
|
| 10 |
...
|
| 11 |
|
|
|
|
| 3 |
from PIL.Image import Image
|
| 4 |
|
| 5 |
|
| 6 |
+
def create_mask(image: Image, blur: bool = ...) -> Image:
|
| 7 |
"""
|
| 8 |
Create a mask from the input image.
|
| 9 |
+
:param image: The input image.
|
| 10 |
+
:param blur: Whether to blur the mask. Default is True.
|
| 11 |
"""
|
| 12 |
...
|
| 13 |
|