From eb9f0be91ada14e41df150127fdfba2b951ce893 Mon Sep 17 00:00:00 2001 From: Sean McLellan Date: Fri, 26 Aug 2022 03:53:55 -0400 Subject: [PATCH 1/5] Set default to none for gfpgan_strength --- scripts/dream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dream.py b/scripts/dream.py index f6feb10adc..5d5e8db4a5 100755 --- a/scripts/dream.py +++ b/scripts/dream.py @@ -496,7 +496,7 @@ def create_cmd_parser(): parser.add_argument( '-G', '--gfpgan_strength', - default=0.5, + default=None, type=float, help='The strength at which to apply the GFPGAN model to the result, in order to improve faces.', ) From 46a223f229c3458f0190813d48e1a52ed5a5ff5a Mon Sep 17 00:00:00 2001 From: Sean McLellan Date: Fri, 26 Aug 2022 04:05:09 -0400 Subject: [PATCH 2/5] Double check for null and 0, and add a comment to indicate intent --- ldm/simplet2i.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index 8aad3557af..dd99f5e6b6 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -305,9 +305,12 @@ class T2I: iter_images = next(images_iterator) for image in iter_images: try: - if gfpgan_strength > 0: - image = self._run_gfpgan( - image, gfpgan_strength + # if gfpgan strength is not none or less than 0.0 then don't use GFPGAN + # if the user specified -G x, and the --gfpgan wasn't specified, then + # the net result is a message gets printed - nothing else happens + if gfpgan_strength is not None and gfpgan_strength > 0.0: + image = self.gfpgan.generate( + image, gfpgan_strength=gfpgan_strength ) except Exception as e: print( From 4e5aa7e714a0230eeefb93dd45c31935e2064587 Mon Sep 17 00:00:00 2001 From: Sean McLellan Date: Fri, 26 Aug 2022 04:07:01 -0400 Subject: [PATCH 3/5] fix comment --- ldm/simplet2i.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index dd99f5e6b6..5c3d08a5d1 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -305,7 +305,7 @@ class T2I: iter_images = next(images_iterator) for image in iter_images: try: - # if gfpgan strength is not none or less than 0.0 then don't use GFPGAN + # if gfpgan strength is none or less than 0.0 then don't use GFPGAN # if the user specified -G x, and the --gfpgan wasn't specified, then # the net result is a message gets printed - nothing else happens if gfpgan_strength is not None and gfpgan_strength > 0.0: From 7bf0bc52086ba0b9259202f90081566c3e91c74c Mon Sep 17 00:00:00 2001 From: Sean McLellan Date: Fri, 26 Aug 2022 04:08:18 -0400 Subject: [PATCH 4/5] fix comment --- ldm/simplet2i.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index 5c3d08a5d1..93a33a6a5d 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -305,9 +305,11 @@ class T2I: iter_images = next(images_iterator) for image in iter_images: try: - # if gfpgan strength is none or less than 0.0 then don't use GFPGAN - # if the user specified -G x, and the --gfpgan wasn't specified, then - # the net result is a message gets printed - nothing else happens + # if gfpgan strength is none or less than or equal to 0.0 then + # don't even attempt to use GFPGAN. + # if the user specified a value of -G that satisifies the condition and + # --gfpgan wasn't specified, at startup then + # the net result is a message gets printed - nothing else happens. if gfpgan_strength is not None and gfpgan_strength > 0.0: image = self.gfpgan.generate( image, gfpgan_strength=gfpgan_strength From f3fad22cb6e24d8672f8548fe6601da91df9ecf6 Mon Sep 17 00:00:00 2001 From: Sean McLellan Date: Fri, 26 Aug 2022 05:27:34 -0400 Subject: [PATCH 5/5] Fix --- ldm/simplet2i.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index 93a33a6a5d..ffec5fda2b 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -311,8 +311,8 @@ class T2I: # --gfpgan wasn't specified, at startup then # the net result is a message gets printed - nothing else happens. if gfpgan_strength is not None and gfpgan_strength > 0.0: - image = self.gfpgan.generate( - image, gfpgan_strength=gfpgan_strength + image = self._run_gfpgan( + image, gfpgan_strength ) except Exception as e: print(