The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.
This is a codebook tokenizer trained on Francesco/underwater-objects-5v7p8 dataset with 12k 16x16 tiles specifically for water. Below is an example of a reconstruction (Image is from the underwater-objects dataset)
Heres the code I used to reconstruct images:
import numpy as np import cv2 import faiss
codebook = np.load("codebook_12k.npy").astype('float32') index = faiss.IndexFlatL2(8) index.add(codebook)
def reconstruct_image(image_path, output_path="reconstructed.png"): img = cv2.imread(image_path) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = cv2.resize(img, (640, 640))
patches = img.reshape(40, 16, 40, 16, 3).swapaxes(1, 2).reshape(-1, 16, 16, 3)
patches_q = (patches / 255.0 * 9).astype(np.float32)
mean_c = patches_q.mean(axis=(1, 2))
std_c = patches_q.std(axis=(1, 2))
bright = patches_q.mean(axis=(1, 2, 3))
sat = np.std(mean_c, axis=1)
feats = np.column_stack([mean_c, std_c, bright, sat])
_, token_ids = index.search(feats, k=1)
token_ids = token_ids.flatten()
reconstructed_patches = []
for tid in token_ids:
mean_rgb = codebook[tid][:3] * (255.0 / 9.0)
block = np.full((16, 16, 3), mean_rgb, dtype=np.uint8)
reconstructed_patches.append(block)
recon_img = np.array(reconstructed_patches).reshape(40, 40, 16, 16, 3)
recon_img = recon_img.swapaxes(1, 2).reshape(640, 640, 3)
cv2.imwrite(output_path, cv2.cvtColor(recon_img, cv2.COLOR_RGB2BGR))
print(f"Test complete! Check {output_path}")
reconstruct_image("your_image.jpg")
- Downloads last month
- 6
