From 4806bb41be06ee7ecabc9314bb8aae184a2d87e6 Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Fri, 14 Mar 2025 11:11:23 +0200 Subject: [PATCH] bugfix --- {examples => example_workflows}/florence_segment_2.json | 0 {examples => example_workflows}/image_batch_bbox_segment.json | 0 .../points_segment_video_example.json | 0 nodes.py | 4 ++-- requirements.txt | 1 - sam2/automatic_mask_generator.py | 4 +++- 6 files changed, 5 insertions(+), 4 deletions(-) rename {examples => example_workflows}/florence_segment_2.json (100%) rename {examples => example_workflows}/image_batch_bbox_segment.json (100%) rename {examples => example_workflows}/points_segment_video_example.json (100%) diff --git a/examples/florence_segment_2.json b/example_workflows/florence_segment_2.json similarity index 100% rename from examples/florence_segment_2.json rename to example_workflows/florence_segment_2.json diff --git a/examples/image_batch_bbox_segment.json b/example_workflows/image_batch_bbox_segment.json similarity index 100% rename from examples/image_batch_bbox_segment.json rename to example_workflows/image_batch_bbox_segment.json diff --git a/examples/points_segment_video_example.json b/example_workflows/points_segment_video_example.json similarity index 100% rename from examples/points_segment_video_example.json rename to example_workflows/points_segment_video_example.json diff --git a/nodes.py b/nodes.py index 7ec181a..f8469fb 100644 --- a/nodes.py +++ b/nodes.py @@ -152,7 +152,7 @@ class Florence2toCoordinates: for idx in indexes: if 0 <= idx < len(data[0]): for i in range(len(data)): - bbox = data[i][idx] + bbox = data[i][idx] if i < len(data) else data[0].get("bboxes", [])[idx] min_x, min_y, max_x, max_y = bbox center_x = int((min_x + max_x) / 2) center_y = int((min_y + max_y) / 2) @@ -161,7 +161,7 @@ class Florence2toCoordinates: else: for idx in indexes: if 0 <= idx < len(data[0]): - bbox = data[0][idx] + bbox = data[0].get("bboxes", [])[idx] if isinstance(data[0], dict) else data[0][idx] min_x, min_y, max_x, max_y = bbox center_x = int((min_x + max_x) / 2) center_y = int((min_y + max_y) / 2) diff --git a/requirements.txt b/requirements.txt index 654d6ea..e55b533 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ pyyaml -numpy<=1.26.4 iopath diff --git a/sam2/automatic_mask_generator.py b/sam2/automatic_mask_generator.py index e589132..4020835 100644 --- a/sam2/automatic_mask_generator.py +++ b/sam2/automatic_mask_generator.py @@ -284,7 +284,9 @@ class SAM2AutomaticMaskGenerator: orig_h, orig_w = orig_size # Run model on this batch - points = torch.as_tensor(points, device=self.predictor.device) + points = torch.as_tensor( + points, dtype=torch.float32, device=self.predictor.device + ) in_points = self.predictor._transforms.transform_coords( points, normalize=normalize, orig_hw=im_size )