add version to infotext, footer and console output when starting
This commit is contained in:
parent
505a10ad92
commit
ab4ab4e595
17
launch.py
17
launch.py
@ -19,6 +19,7 @@ python = sys.executable
|
||||
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:
|
||||
@ -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)
|
||||
@ -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"):
|
||||
|
@ -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
|
||||
|
||||
@ -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)
|
||||
|
@ -394,6 +394,7 @@ options_templates.update(options_section(('ui', "User interface"), {
|
||||
"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"),
|
||||
|
@ -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
|
||||
@ -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__)}
|
||||
@ -1940,7 +1942,5 @@ xformers: {xformers_version}
|
||||
•
|
||||
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>
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user