amazon-science / patchcore-inspection

Apache License 2.0
779 stars 155 forks source link

plot_segmentation_images wrong logic? #94

Open MarcSaghir opened 10 months ago

MarcSaghir commented 10 months ago

Hello, I was just trying to predict on a single image using patchcore. However when i wanted to plot the predictions, it told me that in patchcore.utils in the function plot_segmentation_images the variable mask was referenced before assignment. Having read the code, it seems as if you dont provide mask paths to the function, it will never initialize the variable mask due to the indentation of line 62("else:\n mask = np.zeros_like_image"). This is weird since above that line there are efforts made to catch the case that someone doesnt provide a mask. Can anybody from the team(or elsewhere) please comment if this is a logical flaw or if there is something I am not seeing.

Thank you in advance!

Edit: I just saw this also affects the later plotting of the images because the axes in line 68 have the range of 2 + int(masks_provided), yet there is always axes[2] referenced, regardless of the provided masks

wyweather commented 10 months ago

Hello, have you solved this problem? How should I do to make predictions on a graph

MarcSaghir commented 10 months ago

Hey. A workaround for me was inserting "else: \n mask = np.zeros_like(image)" in line 63, so that when you want to predict wihtout a mask, it gives a empty mask as default.