<jupyter_start><jupyter_text>test bilinear sampling<jupyter_code>from scipy import interpolate
x = np.arange(-5.01, 5.01, 0.25)
y = np.arange(-5.01, 5.01, 0.25)
xx, yy = np.meshgrid(x, y)
z = np.sin(xx**2+yy**2)
f = interpolate.interp2d(x, y, z, kind='cubic')
xnew = np.arange(-5.01, 5.01, 1e-2)
ynew = np.arange(-5.01, 5.01, 1e-2)
znew = f(xnew, ynew)
plt.plot(x, z[0, :], 'ro-', xnew, znew[0, :], 'b-')
plt.show()<jupyter_output><empty_output><jupyter_text>test gaussian kernel<jupyter_code>import os
import sys
# add your module path
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
    sys.path.append(module_path)
# change your base path
os.chdir('../')
print(os.getcwd())
%load_ext autoreload
%autoreload 2
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import gaussian_filter
a = np.arange(50, step=2).reshape((5,5))
a = np.zeros((5,5))
a[2,2] = 1
print("a: ", a)
plt.imshow(a)
plt.show()

a_filtered = gaussian_filter(a, sigma=3)
print("a_filtered: ", a_filtered)
plt.imshow(a_filtered)
plt.show()
from scipy import misc
import matplotlib.pyplot as plt
fig = plt.figure()
plt.gray()  # show the filtered result in grayscale
ax1 = fig.add_subplot(121)  # left side
ax2 = fig.add_subplot(122)  # right side
ascent = misc.ascent()
result = gaussian_filter(ascent, sigma=5)
ax1.imshow(ascent)
ax2.imshow(result)
plt.show()<jupyter_output><empty_output><jupyter_text>extropolate points<jupyter_code>import torch
def extrapolate_points(pnts):
    pnts_int = pnts.long().type(torch.FloatTensor)
    pnts_x, pnts_y = pnts_int[:,0], pnts_int[:,1]

    stack_1 = lambda x, y: torch.stack((x, y), dim=1)
    pnts_ext = torch.cat((pnts_int, stack_1(pnts_x, pnts_y+1),
        stack_1(pnts_x+1, pnts_y), pnts_int+1), dim=0)

    pnts_res = pnts - pnts_int # (x, y)
    x_res, y_res = pnts_res[:,0], pnts_res[:,1] # residuals
    res_ext = torch.cat(((1-x_res)*(1-y_res), (1-x_res)*y_res, 
            x_res*(1-y_res), x_res*y_res), dim=0)
    return pnts_ext, res_ext
import torch
# pnts = torch.tensor([[1.5, 1.5],[2.2, 2.4]])
pnts = torch.tensor([[2.2, 2.4]])
pnts_ext, res_ext = extrapolate_points(pnts)
print("pnts_ext: ", pnts_ext)
print("res_ext: ", res_ext)
# torch.cat()<jupyter_output>pnts_ext:  tensor([[2., 2.],
        [2., 3.],
        [3., 2.],
        [3., 3.]])
res_ext:  tensor([0.4800, 0.3200, 0.1200, 0.0800])<jupyter_text>gaussian augmentation<jupyter_code>import numpy as np
import imgaug.augmenters as iaa
from imgaug import parameters as iap

images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
images = np.zeros((2,5,5,1), dtype=np.uint8)
images[:,2,2] = 255
seq = iaa.Sequential([iaa.GaussianBlur((3.0))])

# images_aug = seq(images)
# images_aug = iaa.GaussianBlur(3.0)(images=images)

# Show an image with 8*8 augmented versions of image 0 and 8*8 augmented
# versions of image 1. Identical augmentations will be applied to
# image 0 and 1.
# seq.show_grid([images[0], images[1]], cols=8, rows=8)

blurer = iaa.GaussianBlur(sigma=0.2)
images_aug = blurer.augment_images(images)
print("images:", images.shape)
plt.imshow(images_aug[0].squeeze())
print("images_aug[0].squeeze() ", images_aug[0].squeeze())
from imgaug import augmenters as iaa
import numpy as np


images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)

# always horizontally flip each input image
images_aug = iaa.Fliplr(1.0)(images=images)

# vertically flip each input image with 90% probability
images_aug = iaa.Flipud(0.9)(images=images)

# blur image 2 by a sigma of 3.0
images_aug = iaa.GaussianBlur(3.0)(images=images)

# move each input image by 8 to 16px to the left
images_aug = iaa.Affine(translate_px={"x": (-8, -16)})(images=images)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1670113753877973, 'fraction_numerical': 0.05118924508790072, 'mean_word_length': 4.970679012345679, 'pattern_counts': {'":': 1, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '666107', 'license': 'MIT', 'n_tokens_mistral': 1755, 'n_tokens_neox': 1624, 'n_words': 350, 'path': 'notebooks/test_gaussian_kernel.ipynb', 'repo_name': 'Dai-z/pytorch-superpoint', 'size': '3868'}