[prompt_segmenting.py] RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
I am facing
I selected 3 points and set them to
input_point = np.array(selected_points)
I'm getting the SAM masks:
I tried adding .cuda() (to mask_pooling_prototype.unsqueeze(0)) and removing .cuda() (in cluster_centers[cluster_mask, :].cuda()) but that didn't help.
Hi, you may need to set the cluster_mask to cuda.
Hi, you may need to set the cluster_mask to cuda.
我也遇到了一样的问题,有时候可以正常运行,但是修改input point或者换场景都有可能出现这个报错
Yes, I encountered it while modifying the input point as well.
当我修改input_point之后遇到了同样的问题,但是我找不到问题出在哪里
我认为我解决了这个问题,当我尝试输出mask_pooling_prototype、cluster_centers、cluster_mask这三个张量运行的设备时,发现cluster_centers运行在cpu上(未修改过代码),然后我在79行报错(我自己是75行)后加入.cuda也不能解决,后发现在计算cluster_centers时,下面加一行 cluster_centers = cluster_centers.cuda(),即可解决