python实现图像固定尺寸批量缩放
import cv2
import os
if __name__ == "__main__":
path = r'' # 目标文件夹路径
folders = os.listdir(path)
for folder in folders:
folder_path = os.path.join(path, folder)
img = cv2.imread(folder_path)
print(img.shape)
resize = cv2.resize(img, (388, 388), interpolation=cv2.INTER_CUBIC) # 定尺寸的缩放
print(resize.shape)
cv2.imwrite(r'\{}'.format(folder), resize)