Solved by gb_pytorch in post #4 
              
              
                This worked for me. Thank you for the tip. @ptrblck 
import sys
import os
from PIL import Image
import numpy as np


mask_dir = "input/"
new_mask_dir = "output/"
if not os.path.exists(new_mask_dir):
    os.mkdir(new_mask_dir)

for filename in os.scandir(mask_dir):
    if filename.path.endswith(".png…