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

Solved error in FastSAMPredictor.postprocess method #251

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

javierganan99
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant