Browse Source

fix typo for Pep8 compliance

tags/v1.2.5
PommeDroid 9 months ago
parent
commit
15ab633ab5
10 changed files with 17 additions and 13 deletions
  1. 3
    0
      argv/run/config.py
  2. 0
    3
      loader/__init__.py
  3. 2
    1
      loader/fs.py
  4. 4
    5
      loader/http.py
  5. 1
    0
      processing/__init__.py
  6. 5
    2
      processing/image.py
  7. BIN
      sample_input.png
  8. 0
    1
      transform/gan/mask.py
  9. 1
    1
      transform/opencv/mask.py
  10. 1
    0
      utils.py

+ 3
- 0
argv/run/config.py View File

@@ -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):
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

+ 0
- 3
loader/__init__.py View File

@@ -1,5 +1,4 @@
"""Loader."""
from config import Config as Conf


class Loader:
@@ -29,5 +28,3 @@ class Loader:
if loader.uri_validator(uri):
return loader
return None



+ 2
- 1
loader/fs.py View File

@@ -1,7 +1,8 @@
""" File Sytem Loading """
import os

from loader import Loader
from utils import read_image
import os


class FSLoader(Loader):

+ 4
- 5
loader/http.py View File

@@ -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(
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
- 0
processing/__init__.py View File

@@ -78,6 +78,7 @@ class Processing:
"""
pass


class SimpleProcessing(Processing):
"""Simple Transform Class."""


+ 5
- 2
processing/image.py View File

@@ -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):

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 View File


+ 0
- 1
transform/gan/mask.py View File

@@ -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)


+ 1
- 1
transform/opencv/mask.py View File

@@ -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
- 0
utils.py View File

@@ -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