Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions label_anything/sam/mmdetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def load_my_model(
class MMDetection(LabelStudioMLBase):
"""Object detector based on https://github.com/open-mmlab/mmdetection."""

_predictor = None
def __init__(self,
model_name="sam_hq",
config_file=None,
Expand All @@ -78,10 +79,13 @@ def __init__(self,
**kwargs):

super(MMDetection, self).__init__(**kwargs)

PREDICTOR = load_my_model(
model_name, device, sam_config, sam_checkpoint_file)
self.PREDICTOR = PREDICTOR

# Only load the model if it hasn't been loaded before
if MMDetection._predictor is None:
MMDetection._predictor = load_my_model(
model_name, device, sam_config, sam_checkpoint_file)

self.PREDICTOR = MMDetection._predictor

self.out_mask = out_mask
self.out_bbox = out_bbox
Expand Down