Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While converting, default option 'None' for sharpen image raises error #356

Closed
zxzl opened this issue Apr 18, 2018 · 2 comments
Closed

While converting, default option 'None' for sharpen image raises error #356

zxzl opened this issue Apr 18, 2018 · 2 comments

Comments

@zxzl
Copy link

zxzl commented Apr 18, 2018

Note: Please only report bugs in this repository. Just because you are getting an error message does not automatically mean you have discovered a bug. If you don't have a lot of experience with this type of project, or if you need for setup help and other issues in using the faceswap tool, please refer to the faceswap-playground instead. The faceswap-playground is also an excellent place to ask questions and submit feedback.

Expected behavior

When giving no option for sharpen image, no sharpen option should be applied
At scripts/convert.py L:115~120

        argument_list.append({ "opts": ('-sh', ),
                               "type": str.lower,
                               "dest": "sharpen_image",
                               "choices": ["bsharpen", "gsharpen"],
                               "default": None,
                               "help": "Use Sharpen Image - bsharpen = Box Blur, gsharpen = Gaussian Blur (Masked converter only)"})

Actual behavior

Error like below pops ups

Traceback (most recent call last):
  File "faceswap.py", line 33, in <module>
    arguments.func(arguments)
  File "/home/kixlab3/Documents/shik/faceswap/lib/cli.py", line 162, in process_arguments
    self.process()
  File "/home/kixlab3/Documents/shik/faceswap/scripts/convert.py", line 191, in process
    self.convert(converter, item)
  File "/home/kixlab3/Documents/shik/faceswap/scripts/convert.py", line 229, in convert
    image = converter.patch_image(image, face, 64 if "128" not in self.arguments.trainer else 128)
  File "/home/kixlab3/Documents/shik/faceswap/plugins/Convert_Masked.py", line 42, in patch_image
    return self.apply_new_face(image, new_face, image_mask, mat, image_size, size)
  File "/home/kixlab3/Documents/shik/faceswap/plugins/Convert_Masked.py", line 50, in apply_new_face
    if "bsharpen" in self.sharpen_image:
TypeError: argument of type 'NoneType' is not iterable

At plugins/Convert_Masked.py

        if "bsharpen" in self.sharpen_image:
            # Sharpening using filter2D
            kernel = numpy.ones((3, 3)) * (-1)
            kernel[1, 1] = 9
            new_image = cv2.filter2D(new_image, -1, kernel)
        elif "gsharpen" in self.sharpen_image:
            # Sharpening using Weighted Method
            gaussain_blur = cv2.GaussianBlur(new_image, (0, 0), 3.0)
            new_image = cv2.addWeighted(
                new_image, 1.5, gaussain_blur, -0.5, 0, new_image)
        elif "none" in self.sharpen_image:
            pass

when self.sharpen_image is None (default value), it cannot be handled correctly

Steps to reproduce

Try converting without giving sharpen option

Other relevant information

  • Command lined used (if not specified in steps to reproduce): faceswap.py ...
  • Operating system and version: Ubuntu 16.04
  • Python version: 3.6.3
  • Faceswap version: a4770a7
  • Faceswap method: GPU
  • Other related issues:
  • ... (for example, installed packages that you can see with pip freeze)
@zxzl zxzl changed the title While converting, Default option 'None' for sharpen image in raise Error While converting, Default option 'None' for sharpen image raises error Apr 18, 2018
@zxzl zxzl changed the title While converting, Default option 'None' for sharpen image raises error While converting, default option 'None' for sharpen image raises error Apr 18, 2018
@zxzl
Copy link
Author

zxzl commented Apr 18, 2018

Can we change the order of checking options as in afead48?

@torzdf
Copy link
Collaborator

torzdf commented Apr 18, 2018

Thanks for the bug report. This is now fixed in commit 8004a72

@torzdf torzdf closed this as completed Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants