from PIL import Image
import numpy as np
# PIL图片转 张量
img = Image.open('cat.jpg')
a = np.asarray(img)
#张量转PIL
img = Image.fromarray(a)
PIL与NumPy图像转换
from PIL import Image
import numpy as np
# PIL图片转 张量
img = Image.open('cat.jpg')
a = np.asarray(img)
#张量转PIL
img = Image.fromarray(a)
1135
1827

被折叠的 条评论
为什么被折叠?