Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,16 +85,16 @@ except Exception as e:
|
|
| 85 |
class CustomSAMWrapper:
|
| 86 |
@spaces.GPU
|
| 87 |
def __init__(self, model_path: str, device: str = DEVICE):
|
| 88 |
-
try:
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
except Exception as e:
|
| 96 |
-
|
| 97 |
-
|
| 98 |
|
| 99 |
def predict(self, image: PILImage.Image,
|
| 100 |
points: List[Tuple[int, int]],
|
|
|
|
| 85 |
class CustomSAMWrapper:
|
| 86 |
@spaces.GPU
|
| 87 |
def __init__(self, model_path: str, device: str = DEVICE):
|
| 88 |
+
# try:
|
| 89 |
+
self.device = torch.device(device)
|
| 90 |
+
sam_model = build_sam2("configs/sam2.1/sam2.1_hiera_l.yaml", model_path, self.device)
|
| 91 |
+
sam_model = sam_model.to(self.device)
|
| 92 |
+
self.predictor = SAM2ImagePredictor(sam_model)
|
| 93 |
+
self.last_mask = None
|
| 94 |
+
print(f"SAM model loaded on {device}")
|
| 95 |
+
# except Exception as e:
|
| 96 |
+
# print(f"Error loading SAM model: {e}")
|
| 97 |
+
# self.predictor = None
|
| 98 |
|
| 99 |
def predict(self, image: PILImage.Image,
|
| 100 |
points: List[Tuple[int, int]],
|