def test_plt_keypoints(): num_monkeys = 1 bm = bad_monkey(num_monkeys) # height, width = bm.size(2), bm.size(3) # heatmap = torch.rand(num_monkeys, 10, height, width, requires_grad=False) # k = MF.spacial_softmax(heatmap) k = torch.empty(1, 5, 2).uniform_(0.0, 1.0) image = plot_keypoints_on_image(k[0], bm[0], radius=7, thickness=3) plt.imshow(image) plt.show()
def test_flowfield(): u = UniImageViewer() x = bad_monkey() theta = torch.tensor([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]).expand(1, -1, -1) grid = F.affine_grid(theta, x.shape) out = F.grid_sample(x, grid) u.render(out[0], block=True)
def test_tps_random(): images = [] u = UniImageViewer(screen_resolution=(2400, 1200)) x = bad_monkey() for i in range(5, 10): set = [] for _ in range(8): pass # set.append(tps_random(x, num_control_points=20, var=1 / i)) st = torch.cat(set, dim=2) images.append(st) img = torch.cat(images, dim=3) u.render(img, block=True)
def test_tps(): u = UniImageViewer() x = bad_monkey() theta = torch.tensor([[[0.0, 0.0], [0., 0.], [0., 0.], [0., 0.], [0., 0.], [0., 0.], [0.0, 0.0]]]) c = torch.tensor([ [0., 0], [1., 0], [1., 1], [0, 1], ]).unsqueeze(0) grid = tps_grid(theta, c, x.shape) out = F.grid_sample(x, grid) u.render(out[0], block=True)
def test_display_keypoints(): x = com.bad_monkey() d = u.ResultsLogger('model_name', 'run_id') k = com.keypoints() d.display(x, blocking=True)
def test_resize(): x = com.bad_monkey() x = u.resize2D(x[0], (512, 512)) d = u.ResultsLogger('model_name', 'run_id') d.display(x, blocking=True)
def test_dual_tps_random_batched(): u = UniImageViewer(screen_resolution=(2400, 1200)) x = bad_monkey(2)