火炬无法保存整数类型上的张量
我尝试使用火炬调整一些我成功完成的图像。调整大小的图像具有整数类型,当我尝试保存它们时,我会收到以下错误:
RuntimeError: result type Float can't be cast to the desired output type Byte
我使用以下代码调整并保存图像:
image_temp = torchvision.transforms.Resize([200,200], antialias = True)(image_temp)
torchvision.utils.save_image(image_temp , './test.png')
如果将张量或图像转换为float类型,则可以保存它而无需错误。有人知道整数数据类型的问题并保存它是什么问题?
I try to use Torch to resize some images which I did successfully. The resized images have integer type and when I try to save them I get the error below:
RuntimeError: result type Float can't be cast to the desired output type Byte
I used the code below to resize and save images:
image_temp = torchvision.transforms.Resize([200,200], antialias = True)(image_temp)
torchvision.utils.save_image(image_temp , './test.png')
If I convert the tensor or the image to float type, I can save it without error. Does someone know what the problem with integer data type and saving it is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论