Spaces:
Paused
Paused
Update modules/masking_module.py
Browse files
modules/masking_module.py
CHANGED
|
@@ -34,13 +34,14 @@ def load_sam_image_model(
|
|
| 34 |
model = build_sam2(config, checkpoint, device=device)
|
| 35 |
return SAM2ImagePredictor(sam_model=model)
|
| 36 |
|
| 37 |
-
|
| 38 |
@spaces.GPU
|
| 39 |
def run_sam_inference(
|
| 40 |
model: Any,
|
| 41 |
image: Image,
|
| 42 |
detections: sv.Detections
|
| 43 |
) -> sv.Detections:
|
|
|
|
| 44 |
image = np.array(image.convert("RGB"))
|
| 45 |
model.set_image(image)
|
| 46 |
print(type(detections.xyxy),detections.xyxy)
|
|
@@ -151,7 +152,7 @@ def masking_process(image,obj):
|
|
| 151 |
# obj = "Tiger"
|
| 152 |
|
| 153 |
Florence_results = florence2(image,task_prompt, text_input=obj)
|
| 154 |
-
|
| 155 |
detections = sv.Detections.from_lmm(
|
| 156 |
lmm=sv.LMM.FLORENCE_2,
|
| 157 |
result=Florence_results,
|
|
|
|
| 34 |
model = build_sam2(config, checkpoint, device=device)
|
| 35 |
return SAM2ImagePredictor(sam_model=model)
|
| 36 |
|
| 37 |
+
|
| 38 |
@spaces.GPU
|
| 39 |
def run_sam_inference(
|
| 40 |
model: Any,
|
| 41 |
image: Image,
|
| 42 |
detections: sv.Detections
|
| 43 |
) -> sv.Detections:
|
| 44 |
+
|
| 45 |
image = np.array(image.convert("RGB"))
|
| 46 |
model.set_image(image)
|
| 47 |
print(type(detections.xyxy),detections.xyxy)
|
|
|
|
| 152 |
# obj = "Tiger"
|
| 153 |
|
| 154 |
Florence_results = florence2(image,task_prompt, text_input=obj)
|
| 155 |
+
SAM_IMAGE_MODEL = load_sam_image_model(device=device)
|
| 156 |
detections = sv.Detections.from_lmm(
|
| 157 |
lmm=sv.LMM.FLORENCE_2,
|
| 158 |
result=Florence_results,
|