Skip to content

Commit abaa31c

Browse files
authored
Add files via upload
1 parent ec76084 commit abaa31c

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

AILab_RMBG.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,8 @@ def load_model(self, model_name):
312312
import transparent_background
313313
self.model = transparent_background.Remover()
314314
self.current_model_version = model_name
315-
except ImportError:
316-
try:
317-
import pip
318-
pip.main(['install', 'transparent_background'])
319-
import transparent_background
320-
self.model = transparent_background.Remover()
321-
self.current_model_version = model_name
322-
except Exception as e:
323-
handle_model_error(f"Failed to install transparent_background: {str(e)}")
315+
except Exception as e:
316+
handle_model_error(f"Failed to initialize transparent_background: {str(e)}")
324317

325318
def process_image(self, image, model_name, params):
326319
try:

AILab_SegmentV2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ def segment_v2(self, image, prompt, sam_model, dino_model, threshold=0.30,
210210
sam_key = (sam_info["model_type"], sam_ckpt_path, device)
211211
if sam_key not in self.sam_model_cache:
212212
try:
213-
sam = sam_model_registry[sam_info["model_type"]](checkpoint=sam_ckpt_path)
213+
sam = sam_model_registry[sam_info["model_type"]]()
214+
state_dict = torch.load(sam_ckpt_path, map_location="cpu")
215+
sam.load_state_dict(state_dict, strict=False)
214216
sam.to(device)
215217
self.sam_model_cache[sam_key] = SamPredictor(sam)
216218
except RuntimeError as e:

requirements.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
# Base dependencies
2-
torch>=2.0.0
3-
torchvision>=0.15.0
4-
Pillow>=9.0.0
5-
numpy>=1.22.0
62
huggingface-hub>=0.19.0
7-
transformers>=4.35.0
8-
safetensors>=0.3.0
9-
transparent-background>=1.2.4
10-
tqdm>=4.65.0
3+
transparent-background>=1.1.2
114
segment-anything>=1.0
125
groundingdino-py>=0.4.0
136
opencv-python>=4.7.0
14-
scipy>=1.10.0
157
onnxruntime>=1.15.0
16-
onnxruntime-gpu>=1.15.0
8+
onnxruntime-gpu>=1.15.0
9+
protobuf>=3.20.2,<6.0.0

0 commit comments

Comments
 (0)