diff --git a/argv.py b/argv.py index 6725cb7..f518edf 100644 --- a/argv.py +++ b/argv.py @@ -70,7 +70,7 @@ class ArgvParser: _, extension = os.path.splitext(a.input) a.output = "output{}".format(extension) elif a.output and os.path.isfile(a.input) and os.path.splitext(a.output)[1] \ - not in cv2_supported_extension(): + not in cv2_supported_extension() + [".gif"]: ArgvParser.parser.error("Output {} file not a supported format.".format(a.output)) def config_args_altered(a): @@ -241,6 +241,12 @@ class ArgvParser: "(,:,) and overlay the result on the original image." ) + scale_mod.add_argument( + "--ignore-size", + action="store_true", + help="Ignore image size checks." + ) + def check_steps_args(): def type_func(a): if not re.match(r"^[0-5]:[0-5]$", a): diff --git a/main.py b/main.py index af5a129..fc09888 100644 --- a/main.py +++ b/main.py @@ -76,8 +76,6 @@ def select_phases(): phases = add_tail(phases, ImageToResizedCrop) elif conf.args['auto_rescale']: phases = add_tail(phases, ImageToRescale) - elif not os.path.isfile(conf.args['input']): - check_shape(read_image(conf.args['input'])) return phases diff --git a/processing/__init__.py b/processing/__init__.py index d523a5d..3918874 100644 --- a/processing/__init__.py +++ b/processing/__init__.py @@ -13,7 +13,7 @@ import imageio import argv from config import Config as conf -from utils import camel_case_to_str, cv2_supported_extension, read_image, write_image, json_to_argv +from utils import camel_case_to_str, cv2_supported_extension, read_image, write_image, json_to_argv, check_shape class Process: @@ -127,6 +127,11 @@ class ImageTransform(Process): self.__starting_step = self._args['steps'][0] if self._args['steps'] else 0 self.__ending_step = self._args['steps'][1] if self._args['steps'] else None + if not conf.args['ignore_size']: + check_shape(read_image(input_path)) + else: + conf.log.warn('Image Size Requirements Unchecked.') + conf.log.debug("All Phases : {}".format(self.__phases)) conf.log.debug("To Be Executed Phases : {}".format(self.__phases[self.__starting_step:self.__ending_step])) diff --git a/transform/gan/__init__.py b/transform/gan/__init__.py index 9590c85..19598db 100644 --- a/transform/gan/__init__.py +++ b/transform/gan/__init__.py @@ -10,7 +10,6 @@ from torchvision import transforms as transforms from config import Config as conf from transform import ImageTransform -from utils import check_shape class ImageTransformGAN(ImageTransform): @@ -37,8 +36,6 @@ class ImageTransformGAN(ImageTransform): :param image: image to be transform :return: None """ - check_shape(image) - if self.__gpu_ids: conf.log.debug("GAN Processing Using GPU IDs: {}".format(self.__gpu_ids)) else: