uni-medical / SAM-Med3D

SAM-Med3D: An Efficient General-purpose Promptable Segmentation Model for 3D Volumetric Medical Image
Apache License 2.0
427 stars 56 forks source link

Sliding Window Issue Aggregation Issue #63

Open timat33 opened 2 months ago

timat33 commented 2 months ago

Hi there,

I'm experiencing an issue with the sliding window aggregation (line 464 of inference.py). I'm working on a dataset that I do not have permission to share, but I could recreate the issue by creating a ground-truth for one of my images, setting a cube at one of the corners to be foreground, and all else background:

fake_gt = np.zeros(gt.shape, dtype=np.uint8) fake_gt[:10, :10, :10] = 1

Then when trying to aggregate, I get ori_roi = (0, -62, 0, -62, 0, -56) pred_roi = (94, 32, 94, 32, 88, 32)

which doesn't permit the insertion of the prediction into the full prediction, ie seg_mask_roi = seg_mask[..., pred_roi[0]:pred_roi[1], pred_roi[2]:pred_roi[3], pred_roi[4]:pred_roi[5]] pred3D_full_dict[idx][..., ori_roi[0]:ori_roi[1], ori_roi[2]:ori_roi[3], ori_roi[4]:ori_roi[5]] = seg_mask_roi gives could not broadcast input array from shape (0,0,0) into shape (1,1,219,160,509)

Which makes sense, the ori_roi's negative indices are meant to be out of bounds, not normal indices, and the pred_roi has eg pred_roi[1]<pred_roi[0] also suggesting that the indexing has gone wrong. I'd appreciate your advice.

Many thanks, Tim

innocence0206 commented 4 weeks ago

I encounter this same promblem, have you solved it?

timat33 commented 4 weeks ago

I'm afraid not