Browse Source

Merge pull request #37 from PommeDroid/ignore_size

Add --ignore-size #32
master
deeppppp 3 years ago committed by GitHub
parent
commit
9793b26f66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      argv.py
  2. 2
      main.py
  3. 7
      processing/__init__.py
  4. 3
      transform/gan/__init__.py

8
argv.py

@ -70,7 +70,7 @@ class ArgvParser: @@ -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: @@ -241,6 +241,12 @@ class ArgvParser:
"(<x_top_left>,<y_top_left>:<x_bot_right>,<x_bot_right>) 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):

2
main.py

@ -76,8 +76,6 @@ def select_phases(): @@ -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

7
processing/__init__.py

@ -13,7 +13,7 @@ import imageio @@ -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): @@ -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]))

3
transform/gan/__init__.py

@ -10,7 +10,6 @@ from torchvision import transforms as transforms @@ -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): @@ -37,8 +36,6 @@ class ImageTransformGAN(ImageTransform):
:param image: <RGB> 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:

Loading…
Cancel
Save