You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to increase the points per side but when I go over 80 I get the following
Traceback (most recent call last):
File "/home/louis/dev/cv/segment-anything/scripts/amg.py", line 267, in <module>
main(args)
File "/home/louis/dev/cv/segment-anything/scripts/amg.py", line 244, in main
masks = generator.generate(image)
File "/home/louis/miniconda3/envs/sam/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/home/louis/dev/cv/segment-anything/segment_anything/automatic_mask_generator.py", line 163, in generate
mask_data = self._generate_masks(image)
File "/home/louis/dev/cv/segment-anything/segment_anything/automatic_mask_generator.py", line 206, in _generate_masks
crop_data = self._process_crop(image, crop_box, layer_idx, orig_size)
File "/home/louis/dev/cv/segment-anything/segment_anything/automatic_mask_generator.py", line 251, in _process_crop
keep_by_nms = batched_nms(
File "/home/louis/miniconda3/envs/sam/lib/python3.10/site-packages/torchvision/ops/boxes.py", line 73, in batched_nms
return _batched_nms_vanilla(boxes, scores, idxs, iou_threshold)
File "/home/louis/miniconda3/envs/sam/lib/python3.10/site-packages/torch/jit/_trace.py", line 1220, in wrapper
return fn(*args, **kwargs)
File "/home/louis/miniconda3/envs/sam/lib/python3.10/site-packages/torchvision/ops/boxes.py", line 110, in _batched_nms_vanilla
keep_mask[curr_indices[curr_keep_indices]] = True
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
I expect this means the curr_keep_indices need to be moved to the same device as the indexed keep_mask tensor.
If we breakpoint at line 251 in _process_crop of automatic_mask_generator.py
# Remove duplicates within this crop.breakpoint()
keep_by_nms=batched_nms(
data["boxes"].float(),
data["iou_preds"],
torch.zeros(len(data["boxes"])), # categoriesiou_threshold=self.box_nms_thresh,
)
data.filter(keep_by_nms)
Note torch.zeros(len(data["boxes"])), # categories does not specify a device
I'm trying to increase the points per side but when I go over 80 I get the following
I expect this means the
curr_keep_indices
need to be moved to the same device as the indexedkeep_mask
tensor.If we breakpoint at line 251 in
_process_crop
ofautomatic_mask_generator.py
torch.zeros(len(data["boxes"])), # categories
does not specify a deviceand enter the debugger
and print the devices of the variables being passed through
batched_nms()
to_batched_nms_vanilla()
:We can confirm that the source of the error is the zeroes which we created without specifying a device, the
boxes
andscores
are on CUDA.To remedy it
or
but I think the first way is more elegant.
I expect the same edit should also be applied on line 360.
to
The text was updated successfully, but these errors were encountered: