Spaces:
Running
on
Zero
Running
on
Zero
kxhit
commited on
Commit
•
b9865ef
1
Parent(s):
e9e22e0
rembg
Browse files- app.py +4 -15
- dust3r/utils/image.py +2 -2
app.py
CHANGED
@@ -5,7 +5,6 @@ print("cuda is available: ", torch.cuda.is_available())
|
|
5 |
import gradio as gr
|
6 |
import os
|
7 |
import shutil
|
8 |
-
import rembg
|
9 |
import numpy as np
|
10 |
import math
|
11 |
import open3d as o3d
|
@@ -74,8 +73,8 @@ from CN_encoder import CN_encoder
|
|
74 |
from pipeline_zero1to3 import Zero1to3StableDiffusionPipeline
|
75 |
from segment_anything import sam_model_registry, SamPredictor
|
76 |
|
77 |
-
|
78 |
-
from carvekit.api.high import HiInterface
|
79 |
|
80 |
|
81 |
pretrained_model_name_or_path = "kxic/EscherNet_demo"
|
@@ -148,19 +147,9 @@ def sam_init():
|
|
148 |
# return interface
|
149 |
|
150 |
|
151 |
-
|
152 |
# rembg_session = create_carvekit_interface()
|
153 |
-
|
154 |
-
batch_size_seg=6,
|
155 |
-
batch_size_matting=1,
|
156 |
-
device=device,
|
157 |
-
seg_mask_size=640, # Use 640 for Tracer B7 and 320 for U2Net
|
158 |
-
matting_mask_size=2048,
|
159 |
-
trimap_prob_threshold=231,
|
160 |
-
trimap_dilation=30,
|
161 |
-
trimap_erosion_iters=5,
|
162 |
-
fp16=True)
|
163 |
-
rembg_session = interface
|
164 |
predictor = sam_init()
|
165 |
|
166 |
|
|
|
5 |
import gradio as gr
|
6 |
import os
|
7 |
import shutil
|
|
|
8 |
import numpy as np
|
9 |
import math
|
10 |
import open3d as o3d
|
|
|
73 |
from pipeline_zero1to3 import Zero1to3StableDiffusionPipeline
|
74 |
from segment_anything import sam_model_registry, SamPredictor
|
75 |
|
76 |
+
import rembg
|
77 |
+
# from carvekit.api.high import HiInterface
|
78 |
|
79 |
|
80 |
pretrained_model_name_or_path = "kxic/EscherNet_demo"
|
|
|
147 |
# return interface
|
148 |
|
149 |
|
150 |
+
rembg_session = rembg.new_session()
|
151 |
# rembg_session = create_carvekit_interface()
|
152 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
predictor = sam_init()
|
154 |
|
155 |
|
dust3r/utils/image.py
CHANGED
@@ -119,9 +119,9 @@ def load_images(folder_or_list, size, square_ok=False, verbose=True, do_remove_b
|
|
119 |
# remove background if needed
|
120 |
if do_remove_background:
|
121 |
# use rembg
|
122 |
-
|
123 |
# use carvekit
|
124 |
-
image_nobg = rembg_session([img])[0]
|
125 |
arr = np.asarray(image_nobg)[:, :, -1]
|
126 |
x_nonzero = np.nonzero(arr.sum(axis=0))
|
127 |
y_nonzero = np.nonzero(arr.sum(axis=1))
|
|
|
119 |
# remove background if needed
|
120 |
if do_remove_background:
|
121 |
# use rembg
|
122 |
+
image_nobg = remove(img, alpha_matting=True, session=rembg_session)
|
123 |
# use carvekit
|
124 |
+
# image_nobg = rembg_session([img])[0]
|
125 |
arr = np.asarray(image_nobg)[:, :, -1]
|
126 |
x_nonzero = np.nonzero(arr.sum(axis=0))
|
127 |
y_nonzero = np.nonzero(arr.sum(axis=1))
|