From d65fab61dff2e4f67365f64318d70eda0dccded1 Mon Sep 17 00:00:00 2001 From: nickroh <48642955+nickroh@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:28:28 -0500 Subject: [PATCH] FEAT: created export & import for image embedding --- mobile_sam/predictor.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mobile_sam/predictor.py b/mobile_sam/predictor.py index 72c7bb9..eac21a2 100644 --- a/mobile_sam/predictor.py +++ b/mobile_sam/predictor.py @@ -30,7 +30,24 @@ def __init__( self.model = sam_model self.transform = ResizeLongestSide(sam_model.image_encoder.img_size) self.reset_image() - + + def import_fields(self, fields): + self.features = fields["features"] + self.orig_h = fields["orig_h"] + self.orig_w = fields["orig_w"] + self.input_h = fields["input_h"] + self.input_w = fields["input_w"] + self.is_image_set = True + + def export_fields(self): + return { + "features": self.features, + "orig_h": self.orig_h, + "orig_w": self.orig_w, + "input_h": self.input_h, + "input_w": self.input_w, + } + def set_image( self, image: np.ndarray,