import sys, json, numpy as np sys.path.insert(0, ".") from fabric_recolor import studio as S from PIL import Image for item in json.load(open(sys.argv[1])): rgb = S._load_rgb(item["image"]); a = S.matte(rgb, S.parse_rects(item.get("exclude"))) Image.fromarray((a*255).round().astype(np.uint8), mode="L").save(item["out"]); print(item["out"], flush=True)