From 617a029ae7a5b632adb181c7c7295d08e05dc591 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sun, 28 Aug 2022 23:12:49 -0400 Subject: [PATCH 1/4] pass outdir from txt2img() and img2img() to prompt2img() correctly --- ldm/simplet2i.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index f1aec32c29..3b869d4614 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -180,11 +180,11 @@ class T2I: return pngwriter.files_written def txt2img(self, prompt, **kwargs): - outdir = kwargs.get('outdir', 'outputs/img-samples') + outdir = kwargs.pop('outdir', 'outputs/img-samples') return self.prompt2png(prompt, outdir, **kwargs) def img2img(self, prompt, **kwargs): - outdir = kwargs.get('outdir', 'outputs/img-samples') + outdir = kwargs.pop('outdir', 'outputs/img-samples') assert ( 'init_img' in kwargs ), 'call to img2img() must include the init_img argument' From 05061a70b383fb00d29dfb27cb36fd7489c110af Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sun, 28 Aug 2022 23:13:23 -0400 Subject: [PATCH 2/4] report errors on non-cuda systems rather than failing silently --- ldm/simplet2i.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index 3b869d4614..ab4778dc44 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -20,6 +20,7 @@ from contextlib import contextmanager, nullcontext import transformers import time import re +import sys from ldm.util import instantiate_from_config from ldm.models.diffusion.ddim import DDIMSampler @@ -540,6 +541,9 @@ class T2I: # model.to doesn't change the cond_stage_model.device used to move the tokenizer output, so set it here self.model.cond_stage_model.device = self.device except AttributeError: + import traceback + print('Error loading model. Only the CUDA backend is supported',file=sys.stderr) + print(traceback.format_exc(),file=sys.stderr) raise SystemExit self._set_sampler() From 03d8eb19e061a3a5ebec432387514eb004dac6bc Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sun, 28 Aug 2022 23:40:04 -0400 Subject: [PATCH 3/4] when no callback used, modify results list so that upscaled/face-fixed image replaces the old one --- ldm/simplet2i.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index ab4778dc44..95ba63dd76 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -350,6 +350,8 @@ class T2I: image_callback(image, seed) else: image_callback(image, seed, upscaled=True) + else: # no callback passed, so we simply replace old image with rescaled one + result[0] = image except KeyboardInterrupt: print('*interrupted*') From 46464ac677695096d1cda2d97bcadb920c1082a2 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sun, 28 Aug 2022 23:45:50 -0400 Subject: [PATCH 4/4] remove unused metadatastr variable --- ldm/simplet2i.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index 95ba63dd76..d2f10c4a81 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -175,8 +175,6 @@ class T2I: outdir, prompt, kwargs.get('batch_size', self.batch_size) ) for r in results: - # gets written into the PNG - metadata_str = f'prompt2png("{prompt}" {kwargs} seed={r[1]}' pngwriter.write_image(r[0], r[1]) return pngwriter.files_written