amazon-science / patchcore-inspection

Apache License 2.0
762 stars 153 forks source link

Needed help urgent .... Segmented image as output #59

Open pseudo-swati opened 1 year ago

pseudo-swati commented 1 year ago

Thank you for providing this code. When I am trying to implement your code , I do not get the image with the segmented area .

Even by trying to save the segmentation images by setting "--save_segmentation_images" , I get the following result.

bottle_test_broken_large_016

I am new to detection could someone please guide me as to how can I get the segmented image as output as shown

Picture1

pseudo-swati commented 1 year ago

Could anybody please help me with this ? I am still not sure how to proceed .

romanvelichkin commented 1 year ago

I think you have to do it yourself, using image-manipulation libraries such as PIL, OpenCV or scikit-image.

wyweather commented 9 months ago

Could anybody please help me with this ? I am still not sure how to proceed .

Have you solved this problem? Please guide me. Thank you.

romanvelichkin commented 9 months ago

Could anybody please help me with this ? I am still not sure how to proceed .

Have you solved this problem? Please guide me. Thank you.

Simple image composing in matplotlib as example:

import matplotlib.pyplot as plt

img = plt.imread(img_path)
mask = plt.imread(mask_path)

plt.figure(figsize = (15,5))
plt.imshow(img)
plt.imshow(mask, alpha=0.20)

This will draw mask with 20% transparency over image. I don't know how to draw mask borders, but I'm pretty sure it's doable, if not in Matplotlib then in Pillow.

If you want to save masked images, then you better compose mask and image using Pillow.

wyweather commented 9 months ago

In Patchcore code utils.py about line 72 ,to obtain this predicted image ,I added axes[3].imshow ...as you written. There is an indexerror: index 3 is out of bounds for axis 0 with size 3. Did you have the predicted image with the Patchcore? If you did , how can I do in details.

romanvelichkin commented 9 months ago

In Patchcore code utils.py about line 72 ,to obtain this predicted image ,I added axes[3].imshow ...as you written. There is an indexerror: index 3 is out of bounds for axis 0 with size 3. Did you have the predicted image with the Patchcore? If you did , how can I do in details.

I'd advise create masks using Patchcore. Model saves them in some of its folders. And after that you can write your own script and mix original images with masks. This will be much faster and easier than edit and debug original code.