Skip to content

Commit

Permalink
feat: add visualizations
Browse files Browse the repository at this point in the history
  • Loading branch information
universome committed Dec 12, 2020
1 parent 8662194 commit f9077ec
Show file tree
Hide file tree
Showing 9 changed files with 557 additions and 65 deletions.
4 changes: 2 additions & 2 deletions cuda/gp_interp_cuda_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ __device__ scalar_t compute_color_bilinear(
// Computing the derivative here is relatively easy
// Since it is a linear function wrt to mu_x and mu_y,
// We just replace them with ones in those places where they are used
scalar_t w_top = (use_d_y ? 1.0 : y) - static_cast<scalar_t>(i);
scalar_t w_left = (use_d_x ? 1.0 : x) - static_cast<scalar_t>(j);
scalar_t w_top = use_d_y ? 1.0 : (y - static_cast<scalar_t>(i));
scalar_t w_left = use_d_x ? 1.0 : (x - static_cast<scalar_t>(j));

// Step 1: interpolate along x-axis
scalar_t color_top = c0 * (1.0 - w_left) + c1 * w_left;
Expand Down
Binary file added cuda/plots/coords-paths.pdf
Binary file not shown.
Binary file added cuda/plots/imagenet-experiments.pdf
Binary file not shown.
Binary file added cuda/plots/optimizing-coords.pdf
Binary file not shown.
Binary file added cuda/room.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
583 changes: 533 additions & 50 deletions cuda/test.ipynb

Large diffs are not rendered by default.

Binary file added cuda/water.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 21 additions & 12 deletions notebooks/guassian-interpolation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -424,30 +424,39 @@
},
{
"cell_type": "code",
"execution_count": 264,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"NEAREST 8.08\n",
"BOX 5.37\n",
"BILINEAR 7.15\n",
"HAMMING 5.57\n",
"BICUBIC 7.57\n",
"LANCZOS 6.51\n"
"NEAREST 0.01511\n",
"BOX 0.01266\n",
"BILINEAR 0.01448\n",
"HAMMING 0.01312\n",
"BICUBIC 0.01511\n",
"LANCZOS 0.01404\n"
]
}
],
"source": [
"from PIL import Image\n",
"import torchvision.transforms.functional as TVF\n",
"\n",
"interps = ['NEAREST', 'BOX', 'BILINEAR', 'HAMMING', 'BICUBIC', 'LANCZOS']\n",
"# img_pil = Image.open('../cuda/water.jpg')\n",
"img_pil = Image.open('../cuda/room.jpg')\n",
"img = TVF.to_tensor(img_pil)\n",
"downsample_size = 0.3\n",
"downsample_size = round(downsample_size * img.shape[1]), round(downsample_size * img.shape[2])\n",
"\n",
"\n",
"for interp in range(6):\n",
" pil_img = TVF.to_pil_image(img.permute(2,0,1).byte())\n",
" downsampled = TVF.resize(pil_img, size=(grid_size + 5,grid_size + 5), interpolation=interp)\n",
" upsampled = TVF.resize(downsampled, size=img.shape[:2], interpolation=interp)\n",
" print(interps[interp], f'{(torch.from_numpy(np.array(upsampled)).unsqueeze(2) - img.float()).abs().mean().item():.02f}')"
" downsampled = TVF.resize(img_pil, size=downsample_size, interpolation=2)\n",
" upsampled = TVF.resize(downsampled, size=(img.shape[1], img.shape[2]), interpolation=interp)\n",
" #print(interps[interp], f'{(TVF.to_tensor(upsampled) - img).pow(2).mean().item():.05f}')\n",
" print(interps[interp], f'{(TVF.to_tensor(upsampled) - img).abs().mean().item():.05f}')"
]
},
{
Expand Down Expand Up @@ -488,7 +497,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/mgp-cuda.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit f9077ec

Please sign in to comment.