FastSAM
FastSAM copied to clipboard
Solved error in FastSAMPredictor.postprocess method
In the postprocess method of FastSAMPredictor, when critical_iou_index is > 1, it raises the following error:
Error: expand(torch.FloatTensor{[2]}, size=[]): the number of sizes provided (0) must be greater or equal to the number of dimensions in the tensor (1)
In line 34 of fastsam.predict.py:
full_box = full_box.view(1, -1)
critical_iou_index = bbox_iou(full_box[0][:4], p[0][:, :4], iou_thres=0.9, image_shape=img.shape[2:])
if critical_iou_index.numel() != 0:
full_box[0][4] = p[0][critical_iou_index][:,4] # ERROR HERE!
full_box[0][6:] = p[0][critical_iou_index][:,6:]
p[0][critical_iou_index] = full_box
It has been solved by returning the bboxes indices sorted by IoU in descending order, and taking the first critical_iou_index.
This may solve #202