Skip to content

Commit

Permalink
Added support for multi resolution style transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
titu1994 committed Jan 28, 2017
1 parent 6a2fcec commit c43f3b4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions INetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def str_to_bool(v):
img_WIDTH = img_HEIGHT = 0
aspect_ratio = 0

assert args.init_image in ["content", "noise", "gray"], "init_image must be one of ['content', 'noise', 'gray']"
assert args.content_loss_type in [0, 1, 2], "Content Loss Type must be one of 0, 1 or 2"


Expand Down Expand Up @@ -561,11 +560,14 @@ def grads(self, x):

if "content" in args.init_image or "gray" in args.init_image:
x = preprocess_image(base_image_path, True, read_mode=read_mode)
else:
elif "noise" in args.init_image:
x = np.random.uniform(0, 255, (1, img_width, img_height, 3)) - 128.

if K.image_dim_ordering() == "th":
x = x.transpose((0, 3, 1, 2))
else:
print("Using initial image : ", args.init_image)
x = preprocess_image(args.init_image, read_mode=read_mode)

# We require original image if we are to preserve color in YCbCr mode
if preserve_color:
Expand Down
6 changes: 4 additions & 2 deletions Network.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def str_to_bool(v):
img_WIDTH = img_HEIGHT = 0
aspect_ratio = 0

assert args.init_image in ["content", "noise", "gray"], "init_image must be one of ['content', 'noise', 'gray']"
assert args.content_loss_type in [0, 1, 2], "Content Loss Type must be one of 0, 1 or 2"


Expand Down Expand Up @@ -537,11 +536,14 @@ def grads(self, x):

if "content" in args.init_image or "gray" in args.init_image:
x = preprocess_image(base_image_path, True, read_mode=read_mode)
else:
elif "noise" in args.init_image:
x = np.random.uniform(0, 255, (1, img_width, img_height, 3)) - 128.

if K.image_dim_ordering() == "th":
x = x.transpose((0, 3, 1, 2))
else:
print("Using initial image : ", args.init_image)
x = preprocess_image(args.init_image, read_mode=read_mode)

# We require original image if we are to preserve color in YCbCr mode
if preserve_color:
Expand Down
Binary file modified script_helper/Neural Style Transfer.exe
Binary file not shown.
Binary file modified script_helper/Neural Style Transfer.pdb
Binary file not shown.
6 changes: 4 additions & 2 deletions script_helper/Script/INetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def str_to_bool(v):
img_WIDTH = img_HEIGHT = 0
aspect_ratio = 0

assert args.init_image in ["content", "noise", "gray"], "init_image must be one of ['content', 'noise', 'gray']"
assert args.content_loss_type in [0, 1, 2], "Content Loss Type must be one of 0, 1 or 2"


Expand Down Expand Up @@ -561,11 +560,14 @@ def grads(self, x):

if "content" in args.init_image or "gray" in args.init_image:
x = preprocess_image(base_image_path, True, read_mode=read_mode)
else:
elif "noise" in args.init_image:
x = np.random.uniform(0, 255, (1, img_width, img_height, 3)) - 128.

if K.image_dim_ordering() == "th":
x = x.transpose((0, 3, 1, 2))
else:
print("Using initial image : ", args.init_image)
x = preprocess_image(args.init_image, read_mode=read_mode)

# We require original image if we are to preserve color in YCbCr mode
if preserve_color:
Expand Down
6 changes: 4 additions & 2 deletions script_helper/Script/Network.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ def str_to_bool(v):
img_WIDTH = img_HEIGHT = 0
aspect_ratio = 0

assert args.init_image in ["content", "noise", "gray"], "init_image must be one of ['content', 'noise', 'gray']"
assert args.content_loss_type in [0, 1, 2], "Content Loss Type must be one of 0, 1 or 2"


Expand Down Expand Up @@ -537,11 +536,14 @@ def grads(self, x):

if "content" in args.init_image or "gray" in args.init_image:
x = preprocess_image(base_image_path, True, read_mode=read_mode)
else:
elif "noise" in args.init_image:
x = np.random.uniform(0, 255, (1, img_width, img_height, 3)) - 128.

if K.image_dim_ordering() == "th":
x = x.transpose((0, 3, 1, 2))
else:
print("Using initial image : ", args.init_image)
x = preprocess_image(args.init_image, read_mode=read_mode)

# We require original image if we are to preserve color in YCbCr mode
if preserve_color:
Expand Down

0 comments on commit c43f3b4

Please sign in to comment.