コード例 #1
0
    train=False)

idx = opt.idx

print("model %d/%d" % (idx, len(d)))

point, seg = d[idx]
print(point.shape, seg.shape)

point_np = point.asnumpy()
ctx = mx.gpu()

cmap = plt.cm.get_cmap("hsv", 10)
cmap = np.array([cmap(i) for i in range(10)])[:, :3]
gt = cmap[seg.asnumpy().astype(np.uint8) - 1, :]

classifier = PointNetDenseCls(k=4)
classifier.load_parameters(opt.model, ctx=ctx)

point = nd.expand_dims(point.transpose((1, 0)), axis=0)

pred, _ = classifier(point.as_in_context(ctx))
pred_choice = pred.argmax(2)
print(pred_choice)

#print(pred_choice.size())
pred_color = cmap[pred_choice.asnumpy().astype(np.uint8)[0], :]

#print(pred_color.shape)
showpoints(point_np, gt, pred_color)
コード例 #2
0
print(len(dataset), len(test_dataset))
num_classes = dataset.num_seg_classes
print('classes', num_classes)
try:
    os.makedirs(opt.outf)
except OSError:
    pass

blue = lambda x: '\033[94m' + x + '\033[0m'

ctx = mx.gpu()
classifier = PointNetDenseCls(k=num_classes, routing=1)
classifier.initialize(ctx=ctx)

if opt.model != '':
    classifier.load_parameters(opt.model)

optimizer = Trainer(classifier.collect_params(), 'sgd', {
    'learning_rate': 0.001,
    'momentum': 0.9
})
L_loss = loss.SoftmaxCrossEntropyLoss()

num_batch = len(dataset) / opt.batchSize

for epoch in range(opt.nepoch):
    correct = 0.
    L = 0.
    count = 0
    L_eval = 0.
    correct_eval = 0.