def rot180(images):
"""
????180??
??HW/CHW/NCHW?????images?
"""
out = np.empty(shape=images.shape, dtype=images.dtype)
if images.ndim == 2:
out = np.rot90(images, k=2)
elif images.ndim == 3:
for c in xrange(images.shape[0]):
out[c] = np.rot90(images[c], k=2)
elif images.ndim == 4:
for n in xrange(images.shape[0]):
for c in xrange(images.shape[1]):
out[n][c] = np.rot90(images[n][c], k=2)
else:
raise Exception('Invalid ndim: ' + str(images.ndim) +
', only support ndim between 2 and 4.')
return out
# ????f????x???f???df???x???
评论列表
文章目录