Skip to content

Commit

Permalink
fix: Use task id in get_local_path sam2 (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
makseq authored Sep 24, 2024
1 parent 0f47d25 commit bbfbeee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions label_studio_ml/examples/segment_anything_2_image/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def get_results(self, masks, probs, width, height, from_name, to_name, label):
'score': total_prob / max(len(results), 1)
}]

def set_image(self, image_url):
image_path = get_local_path(image_url)
def set_image(self, image_url, task_id):
image_path = get_local_path(image_url, task_id=task_id)
image = Image.open(image_path)
image = np.array(image.convert("RGB"))
predictor.set_image(image)

def _sam_predict(self, img_url, point_coords=None, point_labels=None, input_box=None, task=None):
self.set_image(img_url)
self.set_image(img_url, task.get('id'))
point_coords = np.array(point_coords, dtype=np.float32) if point_coords else None
point_labels = np.array(point_labels, dtype=np.float32) if point_labels else None
input_box = np.array(input_box, dtype=np.float32) if input_box else None
Expand Down

0 comments on commit bbfbeee

Please sign in to comment.