Merge branch 'master' into master

This commit is contained in:
Vladimir Mandic
2023-07-20 09:58:48 -04:00
committed by GitHub
10 changed files with 56 additions and 37 deletions
@@ -23,7 +23,7 @@ class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage):
for tag in possible_tags.keys():
if '_' not in tag:
tag = f'0_{tag}'
words = tag.split('_')
words = tag.split('_', 1)
tags[' '.join(words[1:])] = words[0]
# shared.log.debug(f'Lora: {path}: name={name} alias={alias} tags={tags}')
yield {
+4 -6
View File
@@ -2,7 +2,6 @@ async function preloadImages() {
const dark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
const imagePromises = [];
const num = Math.floor(Math.random() * 7) + 1;
const imageUrls = [
`file=html/logo-bg-${dark ? 'dark' : 'light'}.jpg`,
`file=html/logo-bg-${num}.jpg`
@@ -22,7 +21,9 @@ async function preloadImages() {
console.error('Error preloading images:', error);
}
}
async function createSplash() {
await preloadImages();
const dark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
const num = Math.floor(Math.random() * 7) + 1;
const splash = `
@@ -38,8 +39,5 @@ async function removeSplash() {
if (splash) splash.remove();
console.log('removeSplash');
}
async function init() {
await preloadImages();
createSplash();
}
window.onload = init;
window.onload = createSplash;
+2
View File
@@ -13,6 +13,8 @@ function getUICurrentTabContent() {
return gradioApp().querySelector('.tabitem[id^=tab_]:not([style*="display: none"])');
}
const get_uiCurrentTabContent = getUICurrentTabContent;
const get_uiCurrentTab = getUICurrentTab;
const uiAfterUpdateCallbacks = [];
const uiUpdateCallbacks = [];
const uiLoadedCallbacks = [];
+23 -21
View File
@@ -444,41 +444,43 @@ def fix_seed(p):
def create_infotext(p: StableDiffusionProcessing, all_prompts, all_seeds, all_subseeds, comments=None, iteration=0, position_in_batch=0): # pylint: disable=unused-argument
index = position_in_batch + iteration * p.batch_size
token_merging_ratio = p.get_token_merging_ratio()
token_merging_ratio_hr = p.get_token_merging_ratio(for_hr=True)
uses_ensd = shared.opts.eta_noise_seed_delta != 0
if uses_ensd:
uses_ensd = sd_samplers_common.is_sampler_using_eta_noise_seed_delta(p)
generation_params = {
"Version": git_commit,
"Pipeline": 'Diffusers' if shared.backend == shared.Backend.DIFFUSERS else 'Original',
"Steps": p.steps,
"Sampler": p.sampler_name,
"Latent sampler": p.latent_sampler,
"CFG scale": p.cfg_scale,
"Image CFG scale": p.image_cfg_scale if p.enable_hr else None,
"Seed": all_seeds[index],
"Face restoration": shared.opts.face_restoration_model if p.restore_faces else None,
"Sampler": p.sampler_name,
"CFG scale": p.cfg_scale,
"Size": f"{p.width}x{p.height}",
"Model hash": getattr(p, 'sd_model_hash', None if not shared.opts.add_model_hash_to_info or not shared.sd_model.sd_model_hash else shared.sd_model.sd_model_hash),
"Parser": shared.opts.prompt_attention,
"Model": None if not shared.opts.add_model_name_to_info or not shared.sd_model.sd_checkpoint_info.model_name else shared.sd_model.sd_checkpoint_info.model_name.replace(',', '').replace(':', ''),
"Model hash": getattr(p, 'sd_model_hash', None if not shared.opts.add_model_hash_to_info or not shared.sd_model.sd_model_hash else shared.sd_model.sd_model_hash),
"Refiner": None if not shared.opts.add_model_name_to_info or not shared.sd_refiner or not shared.sd_refiner.sd_checkpoint_info.model_name else shared.sd_refiner.sd_checkpoint_info.model_name.replace(',', '').replace(':', ''),
"VAE": None if not shared.opts.add_model_name_to_info or sd_vae.loaded_vae_file is None else os.path.splitext(os.path.basename(sd_vae.loaded_vae_file))[0],
# subseed
"Variation seed": None if p.subseed_strength == 0 else all_subseeds[index],
"Variation seed strength": None if p.subseed_strength == 0 else p.subseed_strength,
# seed resize
"Seed resize from": None if p.seed_resize_from_w == 0 or p.seed_resize_from_h == 0 else f"{p.seed_resize_from_w}x{p.seed_resize_from_h}",
"Denoising strength": p.denoising_strength if p.enable_hr else None,
"Conditional mask weight": getattr(p, "inpainting_mask_weight", shared.opts.inpainting_mask_weight) if p.is_using_inpainting_conditioning else None,
"Clip skip": p.clip_skip if p.clip_skip > 1 else None,
"ENSD": shared.opts.eta_noise_seed_delta if uses_ensd else None,
"Init image hash": getattr(p, 'init_img_hash', None),
"Version": git_commit,
"Token merging ratio": None if token_merging_ratio == 0 else token_merging_ratio,
"Token merging ratio hr": None if not p.enable_hr or token_merging_ratio_hr == 0 else token_merging_ratio_hr,
"Parser": shared.opts.prompt_attention,
"Conditional mask weight": getattr(p, "inpainting_mask_weight", shared.opts.inpainting_mask_weight) if p.is_using_inpainting_conditioning else None,
# clip skip
"Clip skip": p.clip_skip if p.clip_skip > 1 else None,
# ensd
"ENSD": shared.opts.eta_noise_seed_delta if shared.opts.eta_noise_seed_delta != 0 and sd_samplers_common.is_sampler_using_eta_noise_seed_delta(p) else None,
# enable_hr
"Latent sampler": p.latent_sampler if p.enable_hr else None,
"Image CFG scale": p.image_cfg_scale if p.enable_hr else None,
"Denoising strength": p.denoising_strength if p.enable_hr else None,
"Denoise start": p.refiner_denoise_start if p.enable_hr else None,
"Denoise end": p.refiner_denoise_end if p.enable_hr else None,
# restore_faces
"Face restoration": shared.opts.face_restoration_model if p.restore_faces else None,
}
token_merging_ratio = p.get_token_merging_ratio()
token_merging_ratio_hr = p.get_token_merging_ratio(for_hr=True) if p.enable_hr else None
generation_params['Token merging ratio'] = token_merging_ratio if token_merging_ratio != 0 else None
generation_params['Token merging ratio hr'] = token_merging_ratio_hr if token_merging_ratio_hr != 0 else None
generation_params.update(p.extra_generation_params)
generation_params_text = ", ".join([k if k == v else f'{k}: {generation_parameters_copypaste.quote(v)}' for k, v in generation_params.items() if v is not None])
negative_prompt_text = f"\nNegative prompt: {p.all_negative_prompts[index]}" if p.all_negative_prompts[index] else ""
+2
View File
@@ -62,6 +62,8 @@ def is_sampler_using_eta_noise_seed_delta(p):
"""returns whether sampler from config will use eta noise seed delta for image creation"""
sampler_config = sd_samplers.find_sampler_config(p.sampler_name)
eta = p.eta
if not hasattr(p.sampler, "eta"):
return False
if eta is None and p.sampler is not None:
eta = p.sampler.eta
if eta is None and sampler_config is not None:
+1
View File
@@ -889,6 +889,7 @@ def restart_server(restart=True):
demo.close(verbose=False)
demo.server.close()
demo.fns = []
# os._exit(0)
except Exception:
pass
if restart:
+19 -7
View File
@@ -195,17 +195,19 @@ def uninstall_extension(extension_path, search_text, sort_column):
os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
func(path)
ext = [extension for extension in extensions.extensions if os.path.abspath(extension.path) == os.path.abspath(extension_path)]
if len(ext) > 0 and os.path.isdir(extension_path):
found = ext[0]
found = [extension for extension in extensions.extensions if os.path.abspath(extension.path) == os.path.abspath(extension_path)]
if len(found) > 0 and os.path.isdir(extension_path):
found = found[0]
try:
shutil.rmtree(found.path, ignore_errors=False, onerror=errorRemoveReadonly)
# extensions.extensions = [extension for extension in extensions.extensions if os.path.abspath(found.path) != os.path.abspath(extension_path)]
except Exception as e:
shared.log.warning(f'Extension uninstall failed: {found.path} {e}')
extensions.extensions = [extension for extension in extensions.extensions if os.path.abspath(found.path) != os.path.abspath(extension_path)]
update_extension_list()
code = refresh_extensions_list_from_data(search_text, sort_column)
global extensions_list # pylint: disable=global-statement
extensions_list = [ext for ext in extensions_list if ext['name'] != found.name]
shared.log.info(f'Extension uninstalled: {found.path}')
code = refresh_extensions_list_from_data(search_text, sort_column)
return code, f"Extension uninstalled: {found.path} | Restart required"
else:
shared.log.warning(f'Extension uninstall cannot find extension: {extension_path}')
@@ -286,6 +288,8 @@ def refresh_extensions_list_from_data(search_text, sort_column):
</tr>
</thead>
<tbody>"""
if len(extensions_list) == 0:
update_extension_list()
for ext in extensions_list:
extension = [e for e in extensions.extensions
if (e.name == ext['name'])
@@ -310,6 +314,7 @@ def refresh_extensions_list_from_data(search_text, sort_column):
else:
return "N/A"
stats = { 'processed': 0, 'enabled': 0, 'hidden': 0, 'installed': 0 }
for ext in sorted(extensions_list, key=sort_function, reverse=sort_reverse):
name = ext.get("name", "unknown")
added = dt('added')
@@ -340,14 +345,20 @@ def refresh_extensions_list_from_data(search_text, sort_column):
tags = tags + ["installed"] if installed else tags
if len([x for x in tags if x in hide_tags]) > 0:
continue
visible = 'table-row'
if search_text and search_text.strip():
if search_text.lower() not in html.escape(name).lower() and search_text.lower() not in html.escape(description).lower() and search_text.lower() not in html.escape(tags_string).lower():
continue
stats['hidden'] += 1
visible = 'none'
stats['processed'] += 1
version_code = ''
type_code = ''
install_code = ''
enabled_code = ''
if installed:
stats['installed'] += 1
if enabled:
stats['enabled'] += 1
type_code = f"""<div class="type">{"SYSTEM" if ext['is_builtin'] else 'USER'}</div>"""
version_code = f"""<div class="version" style="background: {"--input-border-color-focus" if update_available else "inherit"}">{ext['version']}</div>"""
enabled_code = f"""<input class="gr-check-radio gr-checkbox" name="enable_{html.escape(name)}" type="checkbox" {'checked="checked"' if enabled else ''}>"""
@@ -360,7 +371,7 @@ def refresh_extensions_list_from_data(search_text, sort_column):
install_code = f"""<button onclick="install_extension(this, '{html.escape(url)}')" class="lg secondary gradio-button custom-button extension-button">install</button>"""
tags_text = ", ".join([f"<span class='extension-tag'>{x}</span>" for x in tags])
code += f"""
<tr>
<tr style="display: {visible}">
<td{' class="extension_status"' if ext['installed'] else ''}>{enabled_code}</td>
<td><a href="{html.escape(url)}" target="_blank" class="name">{html.escape(name)}</a><br>{tags_text}</td>
<td>{html.escape(description)}
@@ -372,6 +383,7 @@ def refresh_extensions_list_from_data(search_text, sort_column):
<td>{install_code}</td>
</tr>"""
code += "</tbody></table>"
shared.log.debug(f'Extension list refresh: processed={stats["processed"]} installed={stats["installed"]} enabled={stats["enabled"]} disabled={stats["installed"] - stats["enabled"]} visible={stats["processed"] - stats["hidden"]} hidden={stats["hidden"]}')
return code
+2
View File
@@ -69,6 +69,7 @@ class ExtraNetworksPage:
self.html = ''
self.items = []
self.missing_thumbs = []
# class additional is to keep old extensions happy
self.card = '''
<div class='card' onclick={card_click} title='{title}'>
<div class='overlay'>
@@ -76,6 +77,7 @@ class ExtraNetworksPage:
<div class='name'>{name}</div>
<div class='description'>{description}</div>
<div class='actions'>
<div class='additional'><ul></ul></div>
<span title="Save current image as preview image" onclick={card_save_preview}>💙</span>
<span title="Read description" onclick={card_read_desc}>📖</span>
<span title="Save current description" onclick={card_save_desc}>🛅</span>