This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, sys, numpy as np | |
from scipy import misc, signal | |
from PIL import Image | |
infile, outfile, modelpath = sys.argv[1:] | |
model = json.load(open(modelpath)) | |
im = Image.open(infile).convert("YCbCr") | |
im = misc.fromimage(im.resize((2*im.size[0], 2*im.size[1]), resample=Image.NEAREST)).astype("float32") | |
planes = [np.pad(im[:,:,0], len(model), "edge") / 255.0] | |
for step in model: | |
o_planes = [sum([signal.convolve2d(ip, np.float32(kernel), "valid") |