import os from options.test_options import TestOptions from shutil import move, copyfile from PIL import Image, ImageOps from shutil import copyfile, rmtree import numpy as np import cv2 import subprocess from time import sleep if __name__ == '__main__': opt = TestOptions().parse() opt.nThreads = 1 # test code only supports nThreads = 1 opt.batchSize = 1 # test code only supports batchSize = 1 opt.serial_batches = True # no shuffle opt.no_flip = True # no flip opt.experiment = opt.start_img render_dir = opt.results_dir + opt.experiment + "/" if os.path.exists(render_dir): rmtree(render_dir) mkdirs(render_dir) i = 0 for f in sorted(os.listdir(opt.start_img)): if not os.path.isfile(f): continue pil_image = Image.open(f).convert('RGB') opencv_image = np.array(pil_image) opencv_image = opencv_image[:, :, ::-1].copy() opencv_image = cv2.GaussianBlur(opencv_image, (3,3), 1) opencv_image = cv2.Canny(opencv_image, 100, 200) cv2.imwrite(render_dir + "frame_{:04d}.png".format(i), opencv_image) i += 1