I want to reconstruct the original image
patch_size = (5,5)
new_image = image.reconstruct_from_patches_2d(val_x, ((5, 5, 1)))
plt.subplot(1, 2, 1)
plt.title('Image')
plt.imshow(new_image,cmap='gray' )
error:
help me plz
I want to reconstruct the original image
patch_size = (5,5)
new_image = image.reconstruct_from_patches_2d(val_x, ((5, 5, 1)))
plt.subplot(1, 2, 1)
plt.title('Image')
plt.imshow(new_image,cmap='gray' )
error:
help me plz
I guess you are trying to pass val_x
as a tensor, while sklearn
expects a numpy array, so you could try to pass it as val_x.numpy()
.
@ptrblck the size of original image is (100*100), so I took 40%test. in 40%test I divised image into 3678 patches. But is the same problem
new_image = image.reconstruct_from_patches_2d(val_x.numpy(),(100*100))
plt.subplot(1, 2, 1)
plt.title('Image')
plt.imshow(new_image,cmap='gray' )
The passed image_size
is wrong. The docs explain the input as:
image_sizetuple of int (image_height, image_width) or (image_height, image_width, n_channels)
The size of the image that will be reconstructed.
patch_size = (5,5)
new_image = image.reconstruct_from_patches_2d(val_x.numpy(),(50,50))
plt.subplot(1, 2, 1)
plt.title('Image')
plt.imshow(new_image,cmap='gray' )
It seems your shapes are still wrong, so please check the example and make sure to use the expected shape requirements.
@ptrblck plz , my tensor is equal zeros, but in the image attach values are not equal to tensors
patch_size = (5,5)
print(val_x.shape)
new_image = image.reconstruct_from_patches_2d(val_x.numpy(),(1,5,5))
plt.subplot(5, 5, 1)
plt.title('Image')
plt.imshow(np.squeeze(new_image),cmap='gray' )
image1 = image.extract_patches_2d(mat_diff[‘nouvelle’], ((5,5)))
I toolk 40% of image1 for testing (val_x), I find 3687 patches , then I realised the reconstrcution of this val_x .