Browse Source

fix typo for Pep8 compliance

master
PommeDroid 3 years ago
parent
commit
15ab633ab5
  1. 3
      argv/run/config.py
  2. 3
      loader/__init__.py
  3. 3
      loader/fs.py
  4. 9
      loader/http.py
  5. 1
      processing/__init__.py
  6. 7
      processing/image.py
  7. BIN
      sample_input.png
  8. 1
      transform/gan/mask.py
  9. 2
      transform/opencv/mask.py
  10. 1
      utils.py

3
argv/run/config.py

@ -7,6 +7,7 @@ from loader import Loader @@ -7,6 +7,7 @@ from loader import Loader
from loader.fs import FSLoader
from loader.http import HTTPLoader
def set_args_run_parser(args):
set_arg_checkpoints(args)
set_arg_preference(args)
@ -50,6 +51,8 @@ def check_arg_input(parser, args): @@ -50,6 +51,8 @@ def check_arg_input(parser, args):
elif loader == HTTPLoader:
if not check_url(args.input):
parser.error("Url {} of the http ressource doesn't exist or is not accesible.".format(args.input))
if not is_a_supported_image_file_extension(args.input):
parser.error("Url {} is not file with a supported extension format.".format(args.input))
else:
parser.error("Input {} is not a valid file or directory or url.".format(args.input))
return args.input

3
loader/__init__.py

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
"""Loader."""
from config import Config as Conf
class Loader:
@ -29,5 +28,3 @@ class Loader: @@ -29,5 +28,3 @@ class Loader:
if loader.uri_validator(uri):
return loader
return None

3
loader/fs.py

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
""" File Sytem Loading """
import os
from loader import Loader
from utils import read_image
import os
class FSLoader(Loader):

9
loader/http.py

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
import os
import re
import tempfile
from urllib.parse import urlparse
from utils import dl_file, read_image
from loader import Loader
@ -15,16 +14,16 @@ regex_url = re.compile( @@ -15,16 +14,16 @@ regex_url = re.compile(
r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
class HTTPLoader(Loader):
""" Abstract Loader Class """
@staticmethod
def load(uri):
def run(uri):
"""
Load the http ressource
Run the loader ressource
:return: <RGB> image
"""
_, tmp_path = tempfile.mkstemp()
_, tmp_path = tempfile.mkstemp()
dl_file(uri, tmp_path)
img = read_image(tmp_path)
os.remove(tmp_path)

1
processing/__init__.py

@ -78,6 +78,7 @@ class Processing: @@ -78,6 +78,7 @@ class Processing:
"""
pass
class SimpleProcessing(Processing):
"""Simple Transform Class."""

7
processing/image.py

@ -5,9 +5,10 @@ import sys @@ -5,9 +5,10 @@ import sys
from config import Config as Conf
from processing import Processing
from processing.utils import select_phases
from utils import read_image, camel_case_to_str, write_image
from utils import camel_case_to_str, write_image
from loader import Loader
class ImageProcessing(Processing):
"""Image Processing Class."""
@ -43,7 +44,9 @@ class ImageProcessing(Processing): @@ -43,7 +44,9 @@ class ImageProcessing(Processing):
def _setup(self, *args):
try:
self.__image_steps = [(Loader.get_loader(x)).load(x) if isinstance(x, str) else x for x in self.__image_steps]
self.__image_steps = [
(Loader.get_loader(x)).run(x) if isinstance(x, str) else x for x in self.__image_steps
]
except FileNotFoundError as e:
Conf.log.error(e)
Conf.log.error("{} is not able to resume because it not able to load required images. "

BIN
sample_input.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 KiB

1
transform/gan/mask.py

@ -56,4 +56,3 @@ class MaskfinToNude(MaskImageTransformGAN): @@ -56,4 +56,3 @@ class MaskfinToNude(MaskImageTransformGAN):
:param args: <dict> args parameter to run the image transformation (default use Conf.args)
"""
super().__init__("maskfin_to_nude", input_index=input_index, args=args)

2
transform/opencv/mask.py

@ -155,7 +155,7 @@ class MaskdetToMaskfin(MaskImageTransformOpenCV): @@ -155,7 +155,7 @@ class MaskdetToMaskfin(MaskImageTransformOpenCV):
hairmin = to_int(self.__hair_size, a_min)
self.__draw_ellipse(a_max, a_min, angle, aurmax, aurmin, details, hairmax, hairmin, nipmax, nipmin, obj,
titmax, titmin, vagmax, vagmin, x, y)
titmax, titmin, vagmax, vagmin, x, y)
@staticmethod
def __draw_ellipse(a_max, a_min, angle, aurmax, aurmin, details, hairmax, hairmin, nipmax, nipmin, obj,

1
utils.py

@ -224,6 +224,7 @@ def is_a_supported_image_file_extension(path): @@ -224,6 +224,7 @@ def is_a_supported_image_file_extension(path):
"""
return os.path.splitext(path)[1] in cv2_supported_extension() + [".gif"]
def check_url(url):
"""
Check if a url exists withtout downloading it

Loading…
Cancel
Save