一、利用PIL读取
python
from PIL import Image
img_path="data/train/ants_image/0013035.jpg"
img_PIL=Image.open(img_path)
print(type(img_PIL))
输出:
python
<class 'PIL.JpegImagePlugin.JpegImageFile'>
二、利用opencv读取
python
import cv2
img_path="data/train/ants_image/0013035.jpg"
img_array = cv2.imread(img_path)
print(type(img_array))
输出:
python
<class 'numpy.ndarray'>