【发布时间】:2023-01-26 18:38:23
【问题描述】:
这是我的张量:
import torch
from torchvision import transforms
content:
tensor([[[[0.8939, 0.8700, 0.8458, ..., 0.7610, 0.7093, 0.6909],
.
.
.
[0.4880, 0.5192, 0.5957, ..., 0.8569, 0.9148, 0.9186]]]])
我想将这个 torch.Tensor 转换为 base64。我已经试过了,但我也无法将 PILImage 转换为 base64。
img = transforms.ToPILImage(content)
我怎样才能做到这一点?
【问题讨论】:
-
你的张量有多大?
-
torch.Size([1, 3, 512, 512])