segment-anything
segment-anything copied to clipboard
maybe a bug in the onnx example
the function show_mask in onnx_model_example.ipynb receives the mask as input, while there are usually multiple masks created by the predictor, so in the example point input, the masks is dimensional of (1, N, h, w) , and it can not be reshape to (h, w, 1).
def show_mask(mask, ax): color = np.array([30/255, 144/255, 255/255, 0.6]) h, w = mask.shape[-2:] mask_image = mask.reshape(h, w, 1) * color.reshape(1, 1, -1) ax.imshow(mask_image)
show_mask(masks, plt.gca())
maybe choose one mask show_mask(masks[:,0:1,:,:], plt.gca()) is more reasonable.