diff options
author | yfszzx <yfszzx@gmail.com> | 2022-10-23 08:17:37 +0000 |
---|---|---|
committer | yfszzx <yfszzx@gmail.com> | 2022-10-23 08:17:37 +0000 |
commit | 6a9ea40d7f64139f23d634efd7c2fb2c743a546f (patch) | |
tree | 8d420a5590c09e1d4c005a709166479856e70580 /modules/extras.py | |
parent | 67b78f0ea6f196bfdca49932da062631bb40d0b1 (diff) | |
parent | 1ef32c8b8fa3e16a1e7b287eb19d4fc943d1f2a5 (diff) | |
download | stable-diffusion-webui-gfx803-6a9ea40d7f64139f23d634efd7c2fb2c743a546f.tar.gz stable-diffusion-webui-gfx803-6a9ea40d7f64139f23d634efd7c2fb2c743a546f.tar.bz2 stable-diffusion-webui-gfx803-6a9ea40d7f64139f23d634efd7c2fb2c743a546f.zip |
Move browser and Inspiration into extension
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
|