Skip to content

Commit

Permalink
option to disable save button log.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
w-e-w committed Jul 20, 2024
1 parent b2453d2 commit 24a23e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions modules/shared_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"use_original_name_batch": OptionInfo(True, "Use original name for output filename during batch process in extras tab"),
"use_upscaler_name_as_suffix": OptionInfo(False, "Use upscaler name as filename suffix in the extras tab"),
"save_selected_only": OptionInfo(True, "When using 'Save' button, only save a single selected image"),
"save_write_log_csv": OptionInfo(True, "Write log.csv when saving images using 'Save' button"),
"save_init_img": OptionInfo(False, "Save init images when using img2img"),

"temp_dir": OptionInfo("", "Directory for temporary images; leave empty for default"),
Expand Down
17 changes: 10 additions & 7 deletions modules/ui_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import html
import os
from contextlib import nullcontext

import gradio as gr

Expand Down Expand Up @@ -103,14 +104,15 @@ def __init__(self, d=None):

# NOTE: ensure csv integrity when fields are added by
# updating headers and padding with delimiters where needed
if os.path.exists(logfile_path):
if shared.opts.save_write_log_csv and os.path.exists(logfile_path):
update_logfile(logfile_path, fields)

with open(logfile_path, "a", encoding="utf8", newline='') as file:
at_start = file.tell() == 0
writer = csv.writer(file)
if at_start:
writer.writerow(fields)
with (open(logfile_path, "a", encoding="utf8", newline='') if shared.opts.save_write_log_csv else nullcontext()) as file:
if file:
at_start = file.tell() == 0
writer = csv.writer(file)
if at_start:
writer.writerow(fields)

for image_index, filedata in enumerate(images, start_index):
image = image_from_url_text(filedata)
Expand All @@ -130,7 +132,8 @@ def __init__(self, d=None):
filenames.append(os.path.basename(txt_fullfn))
fullfns.append(txt_fullfn)

writer.writerow([parsed_infotexts[0]['Prompt'], parsed_infotexts[0]['Seed'], data["width"], data["height"], data["sampler_name"], data["cfg_scale"], data["steps"], filenames[0], parsed_infotexts[0]['Negative prompt'], data["sd_model_name"], data["sd_model_hash"]])
if file:
writer.writerow([parsed_infotexts[0]['Prompt'], parsed_infotexts[0]['Seed'], data["width"], data["height"], data["sampler_name"], data["cfg_scale"], data["steps"], filenames[0], parsed_infotexts[0]['Negative prompt'], data["sd_model_name"], data["sd_model_hash"]])

# Make Zip
if do_make_zip:
Expand Down

0 comments on commit 24a23e1

Please sign in to comment.