Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 'numpy.ndarray' object has no attribute 'unsqueeze' when passing bounding boxes into segment_cellular_image #21

Open
ellenemerson opened this issue Jul 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ellenemerson
Copy link

Bounding boxes are converted to ndarray when resized in sam_inference.py (line 234), then unsqueeze is called later as if they are still tensors (line 251). Tested locally by removing the np.array(...) in line 234, and it seems to work - can create a PR if that is helpful.

if boxes_per_heatmap is None:
boxes_per_heatmap = self.generate_bounding_boxes(images, device=device)
else:
boxes_per_heatmap = (
np.array(boxes_per_heatmap) * 1024 / max(images[0].shape)
)
# B, N, 4
if not fast:
boxes_per_heatmap = boxes_per_heatmap[0]
low_masks = []
low_masks_thresholded = []
scores = []
for input_bbox in boxes_per_heatmap:
# if fast , passes N, 4
# else, passes 4
while len(input_bbox.shape) < 2:
input_bbox = input_bbox.unsqueeze(0)

@ellenemerson ellenemerson added the bug Something isn't working label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant