import os import args_manager import modules.config import json import urllib.parse 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): 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') css_styles = ( "" ) js = ( """""" ) begin_part = f"
Fooocus Log {date_string} (private)
\nAll images are clean, without any hidden data/meta, and safe to share with others.
\n\n" end_part = f'\n' middle_part = log_cache.get(html_name, "") if middle_part == "": if os.path.exists(html_name): existing_split = open(html_name, 'r', encoding='utf-8').read().split('') if len(existing_split) == 3: middle_part = existing_split[1] else: middle_part = existing_split[0] div_name = only_name.replace('.', '_') item = f"\n\n" middle_part = item + middle_part with open(html_name, 'w', encoding='utf-8') as f: f.write(begin_part + middle_part + end_part) print(f'Image generated with private log at: {html_name}') log_cache[html_name] = middle_part return