mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-02-06 13:42:52 +08:00
batch processing for img2img with an empty output directory, by request
This commit is contained in:
parent
d15c125db7
commit
43a74fa595
@ -23,8 +23,10 @@ def process_batch(p, input_dir, output_dir, args):
|
|||||||
|
|
||||||
print(f"Will process {len(images)} images, creating {p.n_iter * p.batch_size} new images for each.")
|
print(f"Will process {len(images)} images, creating {p.n_iter * p.batch_size} new images for each.")
|
||||||
|
|
||||||
|
save_normally = output_dir == ''
|
||||||
|
|
||||||
p.do_not_save_grid = True
|
p.do_not_save_grid = True
|
||||||
p.do_not_save_samples = True
|
p.do_not_save_samples = not save_normally
|
||||||
|
|
||||||
state.job_count = len(images) * p.n_iter
|
state.job_count = len(images) * p.n_iter
|
||||||
|
|
||||||
@ -48,6 +50,7 @@ def process_batch(p, input_dir, output_dir, args):
|
|||||||
left, right = os.path.splitext(filename)
|
left, right = os.path.splitext(filename)
|
||||||
filename = f"{left}-{n}{right}"
|
filename = f"{left}-{n}{right}"
|
||||||
|
|
||||||
|
if not save_normally:
|
||||||
processed_image.save(os.path.join(output_dir, filename))
|
processed_image.save(os.path.join(output_dir, filename))
|
||||||
|
|
||||||
|
|
||||||
|
@ -658,7 +658,7 @@ def create_ui(wrap_gradio_gpu_call):
|
|||||||
|
|
||||||
with gr.TabItem('Batch img2img', id='batch'):
|
with gr.TabItem('Batch img2img', id='batch'):
|
||||||
hidden = '<br>Disabled when launched with --hide-ui-dir-config.' if shared.cmd_opts.hide_ui_dir_config else ''
|
hidden = '<br>Disabled when launched with --hide-ui-dir-config.' if shared.cmd_opts.hide_ui_dir_config else ''
|
||||||
gr.HTML(f"<p class=\"text-gray-500\">Process images in a directory on the same machine where the server is running.{hidden}</p>")
|
gr.HTML(f"<p class=\"text-gray-500\">Process images in a directory on the same machine where the server is running.<br>Use an empty output directory to save pictures normally instead of writing to the output directory.{hidden}</p>")
|
||||||
img2img_batch_input_dir = gr.Textbox(label="Input directory", **shared.hide_dirs)
|
img2img_batch_input_dir = gr.Textbox(label="Input directory", **shared.hide_dirs)
|
||||||
img2img_batch_output_dir = gr.Textbox(label="Output directory", **shared.hide_dirs)
|
img2img_batch_output_dir = gr.Textbox(label="Output directory", **shared.hide_dirs)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user