Update app.py
#1
by
MogensR
- opened
app.py
CHANGED
|
@@ -428,10 +428,10 @@ def clear_model(self):
|
|
| 428 |
torch.cuda.empty_cache()
|
| 429 |
gc.collect()
|
| 430 |
|
| 431 |
-
# Professional SAM2 + MatAnyone Pipeline
|
| 432 |
class SAM2MatAnyonePipeline:
|
| 433 |
def __init__(self):
|
| 434 |
-
self.sam2_loader =
|
| 435 |
self.matanyone_loader = MatAnyoneLazy()
|
| 436 |
|
| 437 |
def clear_models(self):
|
|
@@ -608,7 +608,7 @@ def sam2_progress(prog, msg):
|
|
| 608 |
progress(0.1 + prog * 0.15, desc=msg)
|
| 609 |
|
| 610 |
first_frame_rgb = cv2.cvtColor(first_frame, cv2.COLOR_BGR2RGB)
|
| 611 |
-
mask, confidence = professional_pipeline.sam2_loader.
|
| 612 |
first_frame_rgb, model_size, sam2_progress
|
| 613 |
)
|
| 614 |
|
|
@@ -689,7 +689,7 @@ def sam2_progress(prog, msg):
|
|
| 689 |
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 690 |
|
| 691 |
# Segment with SAM2
|
| 692 |
-
alpha, confidence = professional_pipeline.sam2_loader.
|
| 693 |
frame_rgb, model_size, sam2_progress
|
| 694 |
)
|
| 695 |
|
|
|
|
| 428 |
torch.cuda.empty_cache()
|
| 429 |
gc.collect()
|
| 430 |
|
| 431 |
+
# Professional SAM2 + MatAnyone Pipeline with Person Detection
|
| 432 |
class SAM2MatAnyonePipeline:
|
| 433 |
def __init__(self):
|
| 434 |
+
self.sam2_loader = SAM2WithPersonDetection()
|
| 435 |
self.matanyone_loader = MatAnyoneLazy()
|
| 436 |
|
| 437 |
def clear_models(self):
|
|
|
|
| 608 |
progress(0.1 + prog * 0.15, desc=msg)
|
| 609 |
|
| 610 |
first_frame_rgb = cv2.cvtColor(first_frame, cv2.COLOR_BGR2RGB)
|
| 611 |
+
mask, confidence = professional_pipeline.sam2_loader.segment_image_smart(
|
| 612 |
first_frame_rgb, model_size, sam2_progress
|
| 613 |
)
|
| 614 |
|
|
|
|
| 689 |
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 690 |
|
| 691 |
# Segment with SAM2
|
| 692 |
+
alpha, confidence = professional_pipeline.sam2_loader.segment_image_smart(
|
| 693 |
frame_rgb, model_size, sam2_progress
|
| 694 |
)
|
| 695 |
|