mirror of
https://github.com/wassname/PointCNN.git
synced 2026-09-09 11:15:29 +08:00
Significantly clean and document code base. Project approximately complete.
This commit is contained in:
+38
-3
@@ -4,14 +4,16 @@ import torch
|
||||
from torch.autograd import Variable
|
||||
import numpy as np
|
||||
|
||||
from pointcnn.core import XConv, knn_indices_func
|
||||
from PointCNN import XConv, RandPointCNN, knn_indices_func_cpu
|
||||
from PointCNN.tests import plot_pts_and_fts
|
||||
|
||||
np.random.seed(0)
|
||||
|
||||
class BasicTests(unittest.TestCase):
|
||||
""" Basic test cases """
|
||||
|
||||
def test_xconv_shape(self):
|
||||
self.assertTrue(True)
|
||||
np.random.seed(0)
|
||||
|
||||
N = 4
|
||||
D = 3
|
||||
@@ -36,12 +38,45 @@ class BasicTests(unittest.TestCase):
|
||||
P = Variable(torch.from_numpy(P))
|
||||
ps = Variable(torch.from_numpy(ps))
|
||||
|
||||
out = knn_indices_func(ps, P, 2).numpy()
|
||||
out = knn_indices_func_cpu(ps, P, 2).numpy()
|
||||
target = np.array([[[1,2],
|
||||
[2,1]]])
|
||||
|
||||
self.assertTrue(np.array_equal(target, out))
|
||||
|
||||
def test_pointcnn_shape(self):
|
||||
N = 1
|
||||
num_points = 1000
|
||||
dims = 2
|
||||
C_in = 4
|
||||
K = 10
|
||||
D = 1
|
||||
|
||||
layer1 = RandPointCNN(C_in, 8, dims, K, D, 1000, knn_indices_func_cpu).cuda()
|
||||
layer2 = RandPointCNN( 8, 16, dims, K, D, 500, knn_indices_func_cpu).cuda()
|
||||
layer3 = RandPointCNN( 16, 32, dims, K, D, 250, knn_indices_func_cpu).cuda()
|
||||
layer4 = RandPointCNN( 32, 64, dims, K, D, 125, knn_indices_func_cpu).cuda()
|
||||
layer5 = RandPointCNN( 64, 128, dims, K, D, 50, knn_indices_func_cpu).cuda()
|
||||
|
||||
pts = np.random.rand(N,num_points,dims).astype(np.float32)
|
||||
fts = np.random.rand(N,num_points,C_in).astype(np.float32)
|
||||
pts = Variable(torch.from_numpy(pts)).cuda()
|
||||
fts = Variable(torch.from_numpy(fts)).cuda()
|
||||
|
||||
if True:
|
||||
pts, fts = layer1((pts, fts))
|
||||
else:
|
||||
plot_pts_and_fts(pts, fts)
|
||||
pts, fts = layer1((pts, fts))
|
||||
plot_pts_and_fts(pts, fts)
|
||||
pts, fts = layer2((pts, fts))
|
||||
plot_pts_and_fts(pts, fts)
|
||||
pts, fts = layer3((pts, fts))
|
||||
plot_pts_and_fts(pts, fts)
|
||||
pts, fts = layer4((pts, fts))
|
||||
plot_pts_and_fts(pts, fts)
|
||||
pts, fts = layer5((pts, fts))
|
||||
plot_pts_and_fts(pts, fts)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user