Simple implementation of the Jigsaw Puzzle self-supervised task for TensorFlow. It is intented to be used with every dataset as plug and play feature.
This could be implemented as a function that uses out of scope variables, but as we want to have everything as packed as possible, we’re going to define a class that stores the possible combinations and the methods needed to invert the permutations in order to de-puzzle a puzzled image.
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
for img in dst:print(img.shape)breakplt.imshow(img)plt.show()
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
(32, 32, 3)
for img, perm in dst_puzzle:print(img.shape)breakperm = puzler.labels2permutations[perm.numpy()]img_ = puzler.invert_puzzle(img, perm)plt.imshow(puzler.assemble_puzzle(img))plt.title(perm)plt.show()plt.imshow(img_)plt.show()
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).
(4, 16, 16, 3)
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).