diff --git a/INetwork.py b/INetwork.py index 18efd86..4fb29e4 100644 --- a/INetwork.py +++ b/INetwork.py @@ -126,7 +126,7 @@ def str_to_bool(v): style_weights.append(style_weight * args.style_scale) # dimensions of the generated picture. -img_width = img_height = args.img_size +img_width = img_height = 0 img_WIDTH = img_HEIGHT = 0 aspect_ratio = 0 @@ -136,7 +136,7 @@ def str_to_bool(v): # util function to open, resize and format pictures into appropriate tensors def preprocess_image(image_path, load_dims=False, read_mode="color"): - global img_WIDTH, img_HEIGHT, aspect_ratio + global img_width, img_height, img_WIDTH, img_HEIGHT, aspect_ratio mode = "RGB" if read_mode == "color" else "L" img = imread(image_path, mode=mode) # Prevents crashes due to PNG images (ARGB) @@ -155,6 +155,9 @@ def preprocess_image(image_path, load_dims=False, read_mode="color"): img_HEIGHT = img.shape[1] aspect_ratio = img_HEIGHT / img_WIDTH + img_width = args.img_size + img_height = int(img_width * aspect_ratio) + img = imresize(img, (img_width, img_height)).astype('float32') # RGB -> BGR diff --git a/Network.py b/Network.py index e1054ad..c91855d 100644 --- a/Network.py +++ b/Network.py @@ -124,7 +124,7 @@ def str_to_bool(v): style_weights.append(style_weight * args.style_scale) # dimensions of the generated picture. -img_width = img_height = args.img_size +img_width = img_height = 0 img_WIDTH = img_HEIGHT = 0 aspect_ratio = 0 @@ -134,7 +134,7 @@ def str_to_bool(v): # util function to open, resize and format pictures into appropriate tensors def preprocess_image(image_path, load_dims=False, read_mode="color"): - global img_WIDTH, img_HEIGHT, aspect_ratio + global img_width, img_height, img_WIDTH, img_HEIGHT, aspect_ratio mode = "RGB" if read_mode == "color" else "L" img = imread(image_path, mode=mode) # Prevents crashes due to PNG images (ARGB) @@ -153,6 +153,9 @@ def preprocess_image(image_path, load_dims=False, read_mode="color"): img_HEIGHT = img.shape[1] aspect_ratio = img_HEIGHT / img_WIDTH + img_width = args.img_size + img_height = int(img_width * aspect_ratio) + img = imresize(img, (img_width, img_height)).astype('float32') # RGB -> BGR diff --git a/script_helper/Script/INetwork.py b/script_helper/Script/INetwork.py index 18efd86..4fb29e4 100644 --- a/script_helper/Script/INetwork.py +++ b/script_helper/Script/INetwork.py @@ -126,7 +126,7 @@ def str_to_bool(v): style_weights.append(style_weight * args.style_scale) # dimensions of the generated picture. -img_width = img_height = args.img_size +img_width = img_height = 0 img_WIDTH = img_HEIGHT = 0 aspect_ratio = 0 @@ -136,7 +136,7 @@ def str_to_bool(v): # util function to open, resize and format pictures into appropriate tensors def preprocess_image(image_path, load_dims=False, read_mode="color"): - global img_WIDTH, img_HEIGHT, aspect_ratio + global img_width, img_height, img_WIDTH, img_HEIGHT, aspect_ratio mode = "RGB" if read_mode == "color" else "L" img = imread(image_path, mode=mode) # Prevents crashes due to PNG images (ARGB) @@ -155,6 +155,9 @@ def preprocess_image(image_path, load_dims=False, read_mode="color"): img_HEIGHT = img.shape[1] aspect_ratio = img_HEIGHT / img_WIDTH + img_width = args.img_size + img_height = int(img_width * aspect_ratio) + img = imresize(img, (img_width, img_height)).astype('float32') # RGB -> BGR diff --git a/script_helper/Script/Network.py b/script_helper/Script/Network.py index e1054ad..c91855d 100644 --- a/script_helper/Script/Network.py +++ b/script_helper/Script/Network.py @@ -124,7 +124,7 @@ def str_to_bool(v): style_weights.append(style_weight * args.style_scale) # dimensions of the generated picture. -img_width = img_height = args.img_size +img_width = img_height = 0 img_WIDTH = img_HEIGHT = 0 aspect_ratio = 0 @@ -134,7 +134,7 @@ def str_to_bool(v): # util function to open, resize and format pictures into appropriate tensors def preprocess_image(image_path, load_dims=False, read_mode="color"): - global img_WIDTH, img_HEIGHT, aspect_ratio + global img_width, img_height, img_WIDTH, img_HEIGHT, aspect_ratio mode = "RGB" if read_mode == "color" else "L" img = imread(image_path, mode=mode) # Prevents crashes due to PNG images (ARGB) @@ -153,6 +153,9 @@ def preprocess_image(image_path, load_dims=False, read_mode="color"): img_HEIGHT = img.shape[1] aspect_ratio = img_HEIGHT / img_WIDTH + img_width = args.img_size + img_height = int(img_width * aspect_ratio) + img = imresize(img, (img_width, img_height)).astype('float32') # RGB -> BGR