1 Star 2 Fork 1

TaoJIANG/RandLA-Net-pytorch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test.py 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
Alain Riou 提交于 2020-04-11 20:09 . fixed bugs
import numpy as np
from pathlib import Path
import time
import torch
import torch.nn as nn
from data import data_loaders
from model import RandLANet
from utils.ply import read_ply, write_ply
t0 = time.time()
path = Path('datasets') / 's3dis' / 'subsampled' / 'test'
device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
print('Loading data...')
loader, _ = data_loaders(path)
print('Loading model...')
d_in = 6
num_classes = 14
model = RandLANet(d_in, num_classes, 16, 4, device)
model.load_state_dict(torch.load('runs/2020-04-11_17:03/checkpoint_10.pth')['model_state_dict'])
model.eval()
points, labels = next(iter(loader))
print('Predicting labels...')
with torch.no_grad():
points = points.to(device)
labels = labels.to(device)
scores = model(points)
predictions = torch.max(scores, dim=-2).indices
accuracy = (predictions == labels).float().mean() # TODO: compute mIoU usw.
print('Accuracy:', accuracy.item())
predictions = predictions.cpu().numpy()
print('Writing results...')
np.savetxt('output.txt', predictions, fmt='%d', delimiter='\n')
t1 = time.time()
# write point cloud with classes
print('Assigning labels to the point cloud...')
cloud = points.squeeze(0)[:,:3]
write_ply('MiniDijon9.ply', [cloud, predictions], ['x', 'y', 'z', 'class'])
print('Done. Time elapsed: {:.1f}s'.format(t1-t0))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/panpanyunshi/RandLA-Net-pytorch.git
git@gitee.com:panpanyunshi/RandLA-Net-pytorch.git
panpanyunshi
RandLA-Net-pytorch
RandLA-Net-pytorch
master

搜索帮助