Skip to content

Commit

Permalink
add version to infotext, footer and console output when starting
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed May 8, 2023
1 parent 505a10a commit ab4ab4e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
17 changes: 17 additions & 0 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
git = os.environ.get('GIT', "git")
index_url = os.environ.get('INDEX_URL', "")
stored_commit_hash = None
stored_git_tag = None
dir_repos = "repositories"

if 'GRADIO_ANALYTICS_ENABLED' not in os.environ:
Expand Down Expand Up @@ -70,6 +71,20 @@ def commit_hash():
return stored_commit_hash


def git_tag():
global stored_git_tag

if stored_git_tag is not None:
return stored_git_tag

try:
stored_git_tag = run(f"{git} describe --tags").strip()
except Exception:
stored_git_tag = "<none>"

return stored_git_tag


def run(command, desc=None, errdesc=None, custom_env=None, live=False):
if desc is not None:
print(desc)
Expand Down Expand Up @@ -246,8 +261,10 @@ def prepare_environment():
check_python_version()

commit = commit_hash()
tag = git_tag()

print(f"Python {sys.version}")
print(f"Version: {tag}")
print(f"Commit hash: {commit}")

if args.reinstall_torch or not is_installed("torch") or not is_installed("torchvision"):
Expand Down
11 changes: 11 additions & 0 deletions modules/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ def fix_seed(p):
p.subseed = get_fixed_seed(p.subseed)


def program_version():
import launch

res = launch.git_tag()
if res == "<none>":
res = None

return res


def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iteration=0, position_in_batch=0):
index = position_in_batch + iteration * p.batch_size

Expand All @@ -483,6 +493,7 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter
"Init image hash": getattr(p, 'init_img_hash', None),
"RNG": opts.randn_source if opts.randn_source != "GPU" else None,
"NGMS": None if p.s_min_uncond == 0 else p.s_min_uncond,
"Version": program_version() if opts.add_version_to_infotext else None,
}

generation_params.update(p.extra_generation_params)
Expand Down
1 change: 1 addition & 0 deletions modules/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def list_samplers():
"do_not_show_images": OptionInfo(False, "Do not show any images in results for web"),
"add_model_hash_to_info": OptionInfo(True, "Add model hash to generation information"),
"add_model_name_to_info": OptionInfo(True, "Add model name to generation information"),
"add_version_to_infotext": OptionInfo(True, "Add program version to generation information"),
"disable_weights_auto_swap": OptionInfo(True, "When reading generation parameters from text into UI (from PNG info or pasted text), do not change the selected model/checkpoint."),
"send_seed": OptionInfo(True, "Send seed when sending prompt or image to other interface"),
"send_size": OptionInfo(True, "Send size when sending prompt or image to another interface"),
Expand Down
6 changes: 3 additions & 3 deletions modules/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,7 @@ def versions_html():

python_version = ".".join([str(x) for x in sys.version_info[0:3]])
commit = launch.commit_hash()
short_commit = commit[0:8]
tag = launch.git_tag()

if shared.xformers_available:
import xformers
Expand All @@ -1932,6 +1932,8 @@ def versions_html():
xformers_version = "N/A"

return f"""
version: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/{commit}">{tag}</a>
 • 
python: <span title="{sys.version}">{python_version}</span>
 • 
torch: {getattr(torch, '__long_version__',torch.__version__)}
Expand All @@ -1940,7 +1942,5 @@ def versions_html():
 • 
gradio: {gr.__version__}
 • 
commit: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/{commit}">{short_commit}</a>
 • 
checkpoint: <a id="sd_checkpoint_hash">N/A</a>
"""

0 comments on commit ab4ab4e

Please sign in to comment.