image from tensor

        filename1=data['a_name'][0]
        image_tensor=inputs[0]
        pdb.set_trace()
        image_numpy = image_tensor.cpu().float().numpy()
        image_numpy = (np.transpose(image_numpy, (1, 2, 0)) + 1) / 2.0 * 255.0

        from PIL import Image
        xx=Image.fromarray(image_numpy.astype(np.uint8))
        xx.show()
        mm=Image.open(filename1)
        mm.show()
原文地址:https://www.cnblogs.com/skydaddy/p/11719830.html