# Handle images with less than three channels
if len(img.shape) != 3: # 先判断了下是不是三维的
# 不够三维添加一维,反正的弄够三维 img是一个Tensor对象
img = img.unsqueeze(0)
# 就是将最后一维的数据复制一分也用作新添加的那维的数据
img = img.expand((3, img.shape[1:]))
给图片添加一维数据
最新推荐文章于 2024-05-30 07:32:10 发布