import os import args_manager import modules.config from PIL import Image from modules.util import generate_temp_filename log_cache = {} def get_current_html_path(): date_string, local_temp_filename, only_name = generate_temp_filename(folder=modules.config.path_outputs, extension='png') html_name = os.path.join(os.path.dirname(local_temp_filename), 'log.html') return html_name def log(img, dic, single_line_number=3): if args_manager.args.disable_image_log: return date_string, local_temp_filename, only_name = generate_temp_filename(folder=modules.config.path_outputs, extension='png') os.makedirs(os.path.dirname(local_temp_filename), exist_ok=True) Image.fromarray(img).save(local_temp_filename) html_name = os.path.join(os.path.dirname(local_temp_filename), 'log.html') existing_log = log_cache.get(html_name, None) if existing_log is None: if os.path.exists(html_name): existing_log = open(html_name, encoding='utf-8').read() else: existing_log = f'

Fooocus Log {date_string} (private)

\n

All images do not contain any hidden data.

' div_name = only_name.replace('.', '_') item = f'
\n' item += f"

{only_name}

\n" for i, (k, v) in enumerate(dic): if i < single_line_number: item += f"

{k}: {v}

\n" else: if (i - single_line_number) % 2 == 0: item += f"

{k}: {v}, " else: item += f"{k}: {v}

\n" item += f"


\n" existing_log = item + existing_log with open(html_name, 'w', encoding='utf-8') as f: f.write(existing_log) print(f'Image generated with private log at: {html_name}') log_cache[html_name] = existing_log return