图片的读取

import torch
import cv2 as cv
from PIL import Image
import numpy as np

a =  cv.imread('woman.png')
print(a.shape)#[H,W,C]
print(a.dtype)
c = Image.open('woman.png')
print(c.size)#[W,H]
b = np.array(Image.open('woman.png'))
print(b)
print(b.shape)#[H,W,C]
print(b.dtype)
d = torch.from_numpy(b)
print(d)
print(d.shape)
print(d.dtype)
    
原文地址:https://www.cnblogs.com/tingtin/p/14055712.html