Пакетная обработка изображений Python

Как сделать так чтобы этот код обрабатывал по порядку изображения из указанной папки и сохранял их в другую указанную папку.

import os
from imageai.Detection import ObjectDetection


exec_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(os.path.join(
    exec_path, "resnet50_coco_best_v2.1.0.h5")
)

detections = detector.detectObjectsFromImage(
    input_image=os.path.join(exec_path, "input.jpg"),
    output_image_path=os.path.join(exec_path, "output.jpg"),
    minimum_percentage_probability=80,
    display_percentage_probability=True,
    display_object_name=False,
    display_box=True
)
 

for eachObject in detections:
    print(eachObject["name"], " : ", eachObject["percentage_probability"], " : ", eachObject["box_points"])
    print("--------------------------------")

Ответы (0 шт):