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

Challenges in Displaying Prediction Results for Full Images (Unpatchify Issue) #68

Open
SouCh305 opened this issue Jul 8, 2023 · 0 comments

Comments

@SouCh305
Copy link

SouCh305 commented Jul 8, 2023

Hello everyone,

I am working on an image segmentation project in the healthcare domain using the UNet model. Due to the lack of data, I have employed data augmentation by dividing the images into smaller patches of dimensions 256 x 256. After training the model, I proceeded to test it on the test data. Unfortunately, I encountered an issue when displaying the prediction result of the full image. However, when I display the patches individually, the prediction results are correct.

Note: I used the code "206_sem_segm_large_images_using_unet_with_patchify.py" for the testing phase.

This is the testing phase of my code:

`patches = patchify(test_img, (256, 256, 3), step = 128)
predicted_patches = []

for i in range(patches.shape[0]):
for j in range(patches.shape[1]):
print(i,j)
single_patch = patches[i,j,:,:,:,:]
single_patch_prediction = (model.predict(single_patch)[0,:,:,0] > 0.5).astype(np.uint8)
predicted_patches.append(single_patch_prediction)

predicted_patches = np.array(predicted_patches)

predicted_patches_reshaped = np.reshape(predicted_patches, (patches.shape[0], patches.shape[1], 256, 256))
new_array = np.expand_dims(predicted_patches_reshaped, axis=2)
expnd_array = np.repeat(np.expand_dims(new_array, axis=-1), 3, axis=-1)

reconstructed_image = unpatchify(expnd_array, large_image.shape)`

The prediction result of the full image

image

The prediction results of the patches

image

Thank you for helping me!

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

No branches or pull requests

1 participant