diff --git a/scripts/image_browser.py b/scripts/image_browser.py index cb0de40..800a49d 100644 --- a/scripts/image_browser.py +++ b/scripts/image_browser.py @@ -1,14 +1,16 @@ import gradio as gr -import json import logging import os import random +import platform import re import shutil import stat +import sys import time import modules.extras import modules.ui +from modules import paths from modules import script_callbacks from modules import shared, scripts, images from modules.shared import opts, cmd_opts @@ -41,6 +43,7 @@ current_depth = 0 init = True +# Logging logger = logging.getLogger(__name__) logger_mode = logging.ERROR if hasattr(opts, "image_browser_logger_warning"): @@ -53,6 +56,22 @@ console_handler = logging.StreamHandler() console_handler.setLevel(logger_mode) logger.addHandler(console_handler) +# Debug logging +if logger.isEnabledFor(logging.DEBUG): + logger.debug(f"{sys.executable} {sys.version}") + logger.debug(f"{platform.system()} {platform.version()}") + try: + git = os.environ.get('GIT', "git") + commit_hash = os.popen(f"{git} rev-parse HEAD").read() + except Exception as e: + commit_hash = e + logger.debug(f"{commit_hash}") + logger.debug(f"Gradio {gr.__version__}") + logger.debug(f"{paths.script_path}") + with open(cmd_opts.ui_config_file, "r") as f: + logger.debug(f.read()) + with open(cmd_opts.ui_settings_file, "r") as f: + logger.debug(f.read()) def delete_recycle(filename): if opts.image_browser_delete_recycle: @@ -468,16 +487,22 @@ def get_image_page(img_path, page_index, filenames, keyword, sort_by, sort_order load_info += "" return filenames, gr.update(value=page_index, label=f"Page Index ({page_index}/{max_page_index})"), image_list, "", "", "", visible_num, load_info - - def get_current_file(tabname_box, num, page_index, filenames): file = filenames[int(num) + int((page_index - 1) * num_of_imgs_per_page)] return file -def show_image_info(tabname_box, num, page_index, filenames): - file = filenames[int(num) + int((page_index - 1) * num_of_imgs_per_page)] - tm = "