Chao Xu
commited on
Commit
•
1e5adf7
1
Parent(s):
a86e755
remove carvekit
Browse files- ldm/util.py +0 -19
ldm/util.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import importlib
|
2 |
|
3 |
-
import torchvision
|
4 |
import torch
|
5 |
from torch import optim
|
6 |
import numpy as np
|
@@ -15,7 +14,6 @@ from PIL import Image
|
|
15 |
import torch
|
16 |
import time
|
17 |
import cv2
|
18 |
-
from carvekit.api.high import HiInterface
|
19 |
import PIL
|
20 |
|
21 |
def pil_rectangle_crop(im):
|
@@ -43,23 +41,6 @@ def add_margin(pil_img, color, size=256):
|
|
43 |
result.paste(pil_img, ((size - width) // 2, (size - height) // 2))
|
44 |
return result
|
45 |
|
46 |
-
|
47 |
-
def create_carvekit_interface():
|
48 |
-
# Check doc strings for more information
|
49 |
-
interface = HiInterface(object_type="object", # Can be "object" or "hairs-like".
|
50 |
-
batch_size_seg=5,
|
51 |
-
batch_size_matting=1,
|
52 |
-
device='cuda' if torch.cuda.is_available() else 'cpu',
|
53 |
-
seg_mask_size=640, # Use 640 for Tracer B7 and 320 for U2Net
|
54 |
-
matting_mask_size=2048,
|
55 |
-
trimap_prob_threshold=231,
|
56 |
-
trimap_dilation=30,
|
57 |
-
trimap_erosion_iters=5,
|
58 |
-
fp16=False)
|
59 |
-
|
60 |
-
return interface
|
61 |
-
|
62 |
-
|
63 |
def load_and_preprocess(interface, input_im):
|
64 |
'''
|
65 |
:param input_im (PIL Image).
|
|
|
1 |
import importlib
|
2 |
|
|
|
3 |
import torch
|
4 |
from torch import optim
|
5 |
import numpy as np
|
|
|
14 |
import torch
|
15 |
import time
|
16 |
import cv2
|
|
|
17 |
import PIL
|
18 |
|
19 |
def pil_rectangle_crop(im):
|
|
|
41 |
result.paste(pil_img, ((size - width) // 2, (size - height) // 2))
|
42 |
return result
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
def load_and_preprocess(interface, input_im):
|
45 |
'''
|
46 |
:param input_im (PIL Image).
|