报错:

File "/home/xinying/CDCN-Face-Anti-Spoofing.pytorch/trainer/FASTrainer.py", line 153, in train
    depth_map_15, depth_map_8, depth_map_5 = depth_map_15.to(self.device), depth_map_8.to(self.device), depth_map_5.to(self.device)
AttributeError: 'numpy.ndarray' object has no attribute 'to'
depth_maps = torch.tensor(np.array(depth_maps).astype(float))
ValueError: only one element tensors can be converted to Python scalars

要将数组或列表转成tensor类型
数组转tensor,直接:

images = torch.tensor(images)
depth_maps = torch.tensor(depth_maps)
#depth_maps = torch.tensor(np.array(depth_maps).astype(float))
depth_map_15 = torch.tensor(depth_map_15)
depth_map_8 = torch.tensor(depth_map_8)
depth_map_5 = torch.tensor(depth_map_5)
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐