问题:ES6D项目,运行`python train.py --loss_type GADD`,出现报错:
./datasets/tless/models/.pcd
[Open3D WARNING] Read PCD failed: unable to open file: ./datasets/tless/models/.pcd
tensor([], size=(1, 0, 3))
Traceback (most recent call last):
File "train.py", line 475, in <module>
main()
File "train.py", line 116, in main
per_processor(0, opt)
File "train.py", line 232, in per_processor
dataset = pose_dataset('train', opt.num_points, opt.dataset_root, True, opt.noise_trans)
File "/root/autodl-tmp/ES6D/datasets/tless/tless_dataset.py", line 64, in __init__
xyz_ids = farthest_point_sample(raw_xyz, num_pt).cpu().numpy()
File "/root/autodl-tmp/ES6D/datasets/tless/tless_dataset.py", line 222, in farthest_point_sample
farthest = torch.randint(0, N, (B,), dtype=torch.long).to(device)
RuntimeError: random_ expects 'from' to be less than 'to', but got from=0 >= to=0
解决方法:
在"/root/autodl-tmp/ES6D/datasets/tless/tless_dataset.py"文件中,在`while 1`里添加一个检查项:
while 1:
class_input = class_file.readline()
if not class_input:
break
input_cloud = o3d.io.read_point_cloud('{0}/models/{1}.pcd'.format(self.root, class_input[:-1]))
raw_xyz = torch.tensor(np.asarray(input_cloud.points).reshape((1, -1, 3)), dtype=torch.float32)
# 添加if not 检查
if not np.asarray(input_cloud.points).any():
print("No points in point cloud for class: ", class_input)
continue
xyz_ids = farthest_point_sample(raw_xyz, num_pt).cpu().numpy()
raw_xyz = np.asarray(input_cloud.points).astype(np.float32) * 0.001
self.cld.append(raw_xyz[xyz_ids[0, :], :])