diff options
| author | Cameron <cysmith1010@gmail.com> | 2016-10-12 18:58:38 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-12 18:58:38 -0600 |
| commit | d00ab64ce69a9b80cee6e67bddc4f857a0f6ebb0 (patch) | |
| tree | 1ccdce8bb5484bb855f6b552d874d8394f40b797 | |
| parent | 4524885253aafb9928e0859fb1505ce9c22ab06c (diff) | |
| parent | b98313851963e9b0a92825e37f1722fedf07067b (diff) | |
Merge pull request #3 from gtoderici/patch-2
Change interpolation method from bicubic to area.
| -rw-r--r-- | neural_style.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/neural_style.py b/neural_style.py index b62de21..6dc2cf5 100644 --- a/neural_style.py +++ b/neural_style.py @@ -707,10 +707,10 @@ def get_content_image(content_img): # resize if > max size if h > w and h > mx: w = (float(mx) / float(h)) * w - img = cv2.resize(img, dsize=(int(w), mx), interpolation=cv2.INTER_CUBIC) + img = cv2.resize(img, dsize=(int(w), mx), interpolation=cv2.INTER_AREA) if w > mx: h = (float(mx) / float(w)) * h - img = cv2.resize(img, dsize=(mx, int(h)), interpolation=cv2.INTER_CUBIC) + img = cv2.resize(img, dsize=(mx, int(h)), interpolation=cv2.INTER_AREA) img = preprocess(img, vgg19_mean) return img @@ -721,7 +721,7 @@ def get_style_images(content_img): path = os.path.join(args.style_imgs_dir, style_fn) # bgr image img = cv2.imread(path, cv2.IMREAD_COLOR).astype(np.float32) - img = cv2.resize(img, dsize=(cw, ch)) + img = cv2.resize(img, dsize=(cw, ch), interpolation=cv2.INTER_AREA) img = preprocess(img, vgg19_mean) style_imgs.append(img) return style_imgs @@ -735,7 +735,7 @@ def get_noise_image(noise_ratio, content_img): def get_mask_image(mask_img, width, height): path = os.path.join(args.content_img_dir, mask_img) img = cv2.imread(path, cv2.IMREAD_GRAYSCALE) - img = cv2.resize(img, dsize=(width, height)).astype(np.float32) + img = cv2.resize(img, dsize=(width, height), interpolation=cv2.INTER_AREA).astype(np.float32) mx = np.amax(img) img /= mx return img @@ -836,4 +836,4 @@ def main(): else: render_single_image() if __name__ == '__main__': - main()
\ No newline at end of file + main() |
