diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-21 06:49:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 06:49:32 +0000 |
commit | d6bd6a425dd3ed6d9ea10912a17a3618ce68ca30 (patch) | |
tree | dde93ee7ce75ce736fe927e99c461cfa0d26fcae /modules/extras.py | |
parent | d23a46ceaa76af2847f11172f32c92665c268b1b (diff) | |
parent | c23f666dba2b484d521d2dc4be91cf9e09312647 (diff) | |
download | stable-diffusion-webui-gfx803-d6bd6a425dd3ed6d9ea10912a17a3618ce68ca30.tar.gz stable-diffusion-webui-gfx803-d6bd6a425dd3ed6d9ea10912a17a3618ce68ca30.tar.bz2 stable-diffusion-webui-gfx803-d6bd6a425dd3ed6d9ea10912a17a3618ce68ca30.zip |
Merge branch 'master' into master
Diffstat (limited to 'modules/extras.py')
-rw-r--r-- | modules/extras.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/modules/extras.py b/modules/extras.py index b853fa5b..22c5a1c1 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -39,9 +39,12 @@ def run_extras(extras_mode, resize_mode, image, image_folder, input_dir, output_ if input_dir == '':
return outputs, "Please select an input directory.", ''
- image_list = [file for file in [os.path.join(input_dir, x) for x in os.listdir(input_dir)] if os.path.isfile(file)]
+ image_list = [file for file in [os.path.join(input_dir, x) for x in sorted(os.listdir(input_dir))] if os.path.isfile(file)]
for img in image_list:
- image = Image.open(img)
+ try:
+ image = Image.open(img)
+ except Exception:
+ continue
imageArr.append(image)
imageNameArr.append(img)
else:
@@ -118,10 +121,14 @@ def run_extras(extras_mode, resize_mode, image, image_folder, input_dir, output_ while len(cached_images) > 2:
del cached_images[next(iter(cached_images.keys()))]
-
- images.save_image(image, path=outpath, basename="", seed=None, prompt=None, extension=opts.samples_format, info=info, short_filename=True,
- no_prompt=True, grid=False, pnginfo_section_name="extras", existing_info=existing_pnginfo,
- forced_filename=image_name if opts.use_original_name_batch else None)
+
+ if opts.use_original_name_batch and image_name != None:
+ basename = os.path.splitext(os.path.basename(image_name))[0]
+ else:
+ basename = ''
+
+ images.save_image(image, path=outpath, basename=basename, seed=None, prompt=None, extension=opts.samples_format, info=info, short_filename=True,
+ no_prompt=True, grid=False, pnginfo_section_name="extras", existing_info=existing_pnginfo, forced_filename=None)
if opts.enable_pnginfo:
image.info = existing_pnginfo
|