1. cv2.imread()
import cv2
path = {file.jpg}
img = cv2.imread(path)
2. PIL.Image.open()
from PIL import Image
path = {file.jpg}
img = Image.open(path)
3. cv2.imdecode()
import cv2
path = "./root/file.jpg"
with open(path, "rb") as f:
data = f.read()
encoded_img = np.fromstring(data, dtype = np.uinit8)
img = cv2.imdecode(encoded_img, cv2.IMREAD_COLOR)
4. io.BytesIO()
import io
from PIL import Image
path = "./root/file.jpg"
with open(path, "rb") as f:
data = f.read()
data_io = io.BytesIO(data)
img = Image.open(data_io)