Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 891ccb7
Author: Kohaku-Blueleaf <[email protected]>
Date:   Tue Oct 10 15:07:25 2023 +0800

    Fix lint

commit 81e94de
Author: Kohaku-Blueleaf <[email protected]>
Date:   Tue Oct 10 14:44:20 2023 +0800

    Add warning when meet emb name conflicting

    Choose standalone embedding (in /embeddings folder) first

commit 2282eb8
Author: Kohaku-Blueleaf <[email protected]>
Date:   Tue Oct 10 12:11:00 2023 +0800

    Remove dev debug print

commit 3d8b1af
Author: Kohaku-Blueleaf <[email protected]>
Date:   Tue Oct 10 12:09:33 2023 +0800

    Support string_to_param nested dict

    format:
    bundle_emb.EMBNAME.string_to_param.KEYNAME

commit 2aa485b
Author: Kohaku-Blueleaf <[email protected]>
Date:   Mon Oct 9 22:52:09 2023 +0800

    add lora bundle system

commit 7d60076
Author: AUTOMATIC1111 <[email protected]>
Date:   Tue Oct 3 16:22:32 2023 +0300

    case-insensitive search for settings

commit 7717192
Merge: c4ffeb8 c2279da
Author: AUTOMATIC1111 <[email protected]>
Date:   Tue Oct 3 12:38:11 2023 +0300

    Merge pull request AUTOMATIC1111#13475 from wkpark/regress-fix

    fix regression

commit c4ffeb8
Merge: dc2074c e538132
Author: AUTOMATIC1111 <[email protected]>
Date:   Tue Oct 3 12:37:46 2023 +0300

    Merge pull request AUTOMATIC1111#13480 from AUTOMATIC1111/popup-fix

    Fix accidentally closing popup dialogs

commit e538132
Author: missionfloyd <[email protected]>
Date:   Mon Oct 2 22:33:03 2023 -0600

    Lint

commit 86a46e8
Author: missionfloyd <[email protected]>
Date:   Mon Oct 2 22:22:15 2023 -0600

    Fix accidentally closing popup dialogs

commit c2279da
Author: Won-Kyu Park <[email protected]>
Date:   Tue Oct 3 01:16:41 2023 +0900

    fix re_param_code (regression bug PR AUTOMATIC1111#13458)

commit dc2074c
Merge: 362675e 3f763d4
Author: AUTOMATIC1111 <[email protected]>
Date:   Mon Oct 2 13:05:27 2023 +0300

    Merge pull request AUTOMATIC1111#13466 from AUTOMATIC1111/denoising-none

    Change denoising_strength default to None.

commit 362675e
Merge: e3c849d 6ab0b65
Author: AUTOMATIC1111 <[email protected]>
Date:   Mon Oct 2 12:47:02 2023 +0300

    Merge pull request AUTOMATIC1111#13469 from PermissionDenied7335/master

    I found a code snippet in webui.sh that disables python venv and moved it to the appropriate location

commit 6ab0b65
Author: PermissionDenied7335 <[email protected]>
Date:   Mon Oct 2 15:43:59 2023 +0800

    Added an option not to enable venv

commit 3f763d4
Author: missionfloyd <[email protected]>
Date:   Sun Oct 1 22:38:27 2023 -0600

    Change denoising_strength default to None.

commit e3c849d
Merge: c011387 deeec0b
Author: AUTOMATIC1111 <[email protected]>
Date:   Sun Oct 1 11:49:42 2023 +0300

    Merge pull request AUTOMATIC1111#13458 from wkpark/fieldname-regex

    fix fieldname regex

commit c011387
Author: AUTOMATIC1111 <[email protected]>
Date:   Sun Oct 1 11:48:41 2023 +0300

    add search field to settings

commit deeec0b
Author: Won-Kyu Park <[email protected]>
Date:   Sun Oct 1 00:25:53 2023 +0900

    fix fieldname regex to accept additional [-/] chars

commit c7e810a
Author: AUTOMATIC1111 <[email protected]>
Date:   Sun Oct 1 10:15:23 2023 +0300

    add onEdit function for js and rework token-counter.js to use it

commit 7026b96
Merge: b2f9709 56ef5e9
Author: AUTOMATIC1111 <[email protected]>
Date:   Sun Oct 1 07:04:08 2023 +0300

    Merge pull request AUTOMATIC1111#13444 from AUTOMATIC1111/edit-attn-delimiters

    edit-attention: Allow editing whitespace delimiters

commit 56ef5e9
Author: missionfloyd <[email protected]>
Date:   Sat Sep 30 21:44:05 2023 -0600

    Remove end parenthesis from weight

commit 0eb5fde
Author: missionfloyd <[email protected]>
Date:   Sat Sep 30 21:20:58 2023 -0600

    Remove unneeded code

commit 0935d2c
Author: missionfloyd <[email protected]>
Date:   Sat Sep 30 18:37:44 2023 -0600

    Use checkboxes for whitespace delimiters

commit b2f9709
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 10:29:10 2023 +0300

    get AUTOMATIC1111#13121 to work without restart

commit 5cc7bf3
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 10:10:57 2023 +0300

    reword sd_checkpoint_dropdown_use_short setting and add explanation

commit 416fbde
Merge: 951842d 4588170
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 10:09:45 2023 +0300

    Merge pull request AUTOMATIC1111#13121 from AUTOMATIC1111/consolidated-allowed-preview-formats

    Consolidated allowed preview formats, Fix extra network `.gif` not woking as preview

commit 1cc7c4b
Author: missionfloyd <[email protected]>
Date:   Sat Sep 30 01:09:09 2023 -0600

    Allow editing whitespace delimiters

commit 951842d
Merge: 591ad1d 63485b2
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 10:02:28 2023 +0300

    Merge pull request AUTOMATIC1111#13139 from AUTOMATIC1111/ckpt-dir-path-separator

    fix `--ckpt-dir` path separator and option use `short name` for checkpoint dropdown

commit 591ad1d
Merge: fcfe5c1 ab57417
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:59:21 2023 +0300

    Merge pull request AUTOMATIC1111#13170 from AUTOMATIC1111/re-fix-batch-img2img-output-dir-with-script

    Re fix batch img2img output dir with script

commit fcfe5c1
Merge: a0e979b 26d0d87
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:49:37 2023 +0300

    Merge pull request AUTOMATIC1111#12877 from zixaphir/removeExtraNetworksFromPrompt_fix

    account for customizable extra network separators in remove code

commit a0e979b
Merge: 3aa9f01 7d4d871
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:48:38 2023 +0300

    Merge pull request AUTOMATIC1111#13178 from wpdong0727/fix-lora-bias-backup-reset

    fix: lora-bias-backup don't reset cache

commit 3aa9f01
Merge: 4e5d252 413123f
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:47:52 2023 +0300

    Merge pull request AUTOMATIC1111#13077 from sdwebui-extensions/master

    fix localization when there are multi same localization file in the extensions

commit 4e5d252
Merge: ab63054 c485a7d
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:46:55 2023 +0300

    Merge pull request AUTOMATIC1111#13189 from AUTOMATIC1111/make-InputAccordion-work-with-ui-config

    make InputAccordion work with ui-config

commit ab63054
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:34:50 2023 +0300

    write infotext to gif image as comment

commit 0c71967
Merge: b20cd35 022639a
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:33:14 2023 +0300

    Merge pull request AUTOMATIC1111#13068 from JaredTherriault/master

    Load comments from gif images to gather geninfo from gif outputs

commit b20cd35
Merge: 3a4290f 5b761b4
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:23:32 2023 +0300

    Merge pull request AUTOMATIC1111#13210 from AUTOMATIC1111/fetch-version-info-when-webui_dir-is-not-work_dir-

    fix issues when webui_dir is not work_dir

commit 3a4290f
Merge: df48222 cf1edc2
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:21:47 2023 +0300

    Merge pull request AUTOMATIC1111#13229 from AUTOMATIC1111/initialize-state.time_start-befroe-state.job_count

    initialize state.time_start befroe state.job_count

commit df48222
Merge: ee8e987 0ad38a9
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:21:08 2023 +0300

    Merge pull request AUTOMATIC1111#13231 from der3318/better-support-for-portable-git

    Better Support for Portable Git

commit ee8e987
Merge: 87b5039 afd0624
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:17:24 2023 +0300

    Merge pull request AUTOMATIC1111#13266 from wkpark/xyz-prepare

    xyz_grid: add prepare

commit 87b5039
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:11:31 2023 +0300

    add missing import, simplify code, use patches module for AUTOMATIC1111#13276

commit e309583
Merge: 7ce1f3a d9d9414
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 09:01:12 2023 +0300

    Merge pull request AUTOMATIC1111#13276 from woweenie/patch-1

    patch DDPM.register_betas so that users can put given_betas in model yaml

commit 7ce1f3a
Merge: db63cf7 663fb87
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:59:28 2023 +0300

    Merge pull request AUTOMATIC1111#13281 from AUTOMATIC1111/Config-states-time-ISO-in-system-time-zone

    Config states time ISO in system time zone

commit db63cf7
Merge: cdafbca d2878a8
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:58:07 2023 +0300

    Merge pull request AUTOMATIC1111#13282 from AUTOMATIC1111/XYZ-if-not-Include-Sub-Grids-do-not-save-Sub-Grid

    XYZ if not include sub grids do not save sub grid

commit cdafbca
Merge: 34055f9 8e355fb
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:55:54 2023 +0300

    Merge pull request AUTOMATIC1111#13313 from chu8129/dev

    use orderdict as lru cache:opt/bug

commit 34055f9
Merge: 9b17416 701feab
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:49:26 2023 +0300

    Merge pull request AUTOMATIC1111#13302 from Zolxys/patch-1

    Fix: --sd_model in "Prompts from file or textbox" script is not working

commit 9b17416
Merge: 833b9b6 fdecf81
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:46:48 2023 +0300

    Merge pull request AUTOMATIC1111#13372 from ezt19/patch-1

    Update dragdrop.js

commit 833b9b6
Merge: 3b0be0f d00f6dc
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:32:38 2023 +0300

    Merge pull request AUTOMATIC1111#13395 from AUTOMATIC1111/escape-names

    Fix viewing/editing metadata when filename contains an apostrophe

commit 3b0be0f
Merge: 4083639 99aa702
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:32:07 2023 +0300

    Merge pull request AUTOMATIC1111#13411 from AUTOMATIC1111/update-card-metadata

    Update card on correct tab when editing metadata

commit 4083639
Merge: 8a75838 30f4f25
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:31:30 2023 +0300

    Merge pull request AUTOMATIC1111#13418 from akx/torchsde-bump

    Bump to torchsde==0.2.6

commit 8a75838
Merge: ad3b8a1 a69daae
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:24:37 2023 +0300

    Merge pull request AUTOMATIC1111#13412 from AUTOMATIC1111/data-sort-name-fix

    Fix data-sort-name containing spaces

commit ad3b8a1
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:23:12 2023 +0300

    alternative solution to AUTOMATIC1111#13434

commit 1b9ca01
Merge: 102b661 ab3d352
Author: AUTOMATIC1111 <[email protected]>
Date:   Sat Sep 30 08:15:00 2023 +0300

    Merge pull request AUTOMATIC1111#13253 from LeonZhao28/feature_skip_load_model_at_start

    add --skip-load-model-at-start

commit 30f4f25
Author: Aarni Koskela <[email protected]>
Date:   Wed Sep 27 10:21:14 2023 +0300

    Bump to torchsde==0.2.6

commit a69daae
Author: missionfloyd <[email protected]>
Date:   Tue Sep 26 22:02:52 2023 -0600

    Fix data-sort-name containing spaces

commit 99aa702
Author: missionfloyd <[email protected]>
Date:   Tue Sep 26 21:08:55 2023 -0600

    Update card on correct tab

commit d00f6dc
Author: missionfloyd <[email protected]>
Date:   Mon Sep 25 22:08:24 2023 -0600

    Escape item names

commit fdecf81
Author: ezt19 <[email protected]>
Date:   Sat Sep 23 20:41:28 2023 +0000

    Update dragdrop.js

    Fixing a problem when u cannot put two images and they are going into two different places for images.

commit 8e355fb
Author: 王秋文/qwwang <[email protected]>
Date:   Mon Sep 18 16:45:42 2023 +0800

    fix

commit 701feab
Author: Zolxys <[email protected]>
Date:   Sun Sep 17 11:37:15 2023 -0500

    Fix: --sd_model in "Promts from file or textbox" script is not working

    Fix for bug report AUTOMATIC1111#8079

commit d9d9414
Author: woweenie <[email protected]>
Date:   Fri Sep 15 18:59:44 2023 +0200

    patch DDPM.register_betas so that users can put given_betas in model yaml

commit 813535d
Author: qiuwen.wang <[email protected]>
Date:   Fri Sep 15 18:23:23 2023 +0800

    use dict[key]=model; did not update orderdict order, should use move to end

commit afd0624
Author: Won-Kyu Park <[email protected]>
Date:   Fri Sep 15 17:10:01 2023 +0900

    xyz_grid: add prepare option to AxisOption

commit ab3d352
Author: Leon <[email protected]>
Date:   Thu Sep 14 18:42:56 2023 +0800

    add --skip-load-model-at-start

commit 0ad38a9
Author: Der Chien <[email protected]>
Date:   Wed Sep 13 20:20:01 2023 +0800

    20230913 setup GIT_PYTHON_GIT_EXECUTABLE for GitPython

commit cf1edc2
Author: w-e-w <[email protected]>
Date:   Wed Sep 13 16:27:02 2023 +0900

    initialize state.time_start befroe state.job_count

commit c485a7d
Author: w-e-w <[email protected]>
Date:   Mon Sep 11 13:47:44 2023 +0900

    make InputAccordion work with ui-config

commit 413123f
Author: liubo0902 <[email protected]>
Date:   Mon Sep 11 09:22:27 2023 +0800

    Update localization.py

commit 7d4d871
Author: dongwenpu <[email protected]>
Date:   Sun Sep 10 17:53:42 2023 +0800

    fix: lora-bias-backup don't reset cache

commit 26d0d87
Author: zixaphir <[email protected]>
Date:   Sat Sep 9 17:26:46 2023 -0700

    Remove extra spaces

commit d6478a6
Author: zixaphir <[email protected]>
Date:   Sat Sep 9 17:22:10 2023 -0700

    Remove extra network separator without regex

commit 63485b2
Author: w-e-w <[email protected]>
Date:   Fri Sep 8 10:00:27 2023 +0900

    option use short name for checkpoint dropdown

commit e4726cc
Author: w-e-w <[email protected]>
Date:   Fri Sep 8 09:46:34 2023 +0900

    parsing string to path

commit 4588170
Author: w-e-w <[email protected]>
Date:   Thu Sep 7 12:11:36 2023 +0900

    consolidated allowed preview formats

commit ff7027f
Author: liubo0902 <[email protected]>
Date:   Tue Sep 5 15:08:59 2023 +0800

    Update localization.py

commit 0c1c9e7
Author: liubo0902 <[email protected]>
Date:   Tue Sep 5 15:06:47 2023 +0800

    Update localization.py

commit 022639a
Author: JaredTherriault <[email protected]>
Date:   Mon Sep 4 17:37:48 2023 -0700

    Load comments from gif images to gather geninfo from gif outputs

commit 5e16914
Merge: 8f3b02f 5ef669d
Author: JaredTherriault <[email protected]>
Date:   Mon Sep 4 17:29:33 2023 -0700

    Merge branch 'AUTOMATIC1111:master' into master

commit 8f3b02f
Author: JaredTherriault <[email protected]>
Date:   Sun Sep 3 13:31:42 2023 -0700

    Revert "Offloading custom work"

    This reverts commit f3d1631.

    This work has been offloaded now into an extension called Prompt Control.

commit 78c1a74
Author: zixaphir <[email protected]>
Date:   Thu Aug 31 14:18:35 2023 -0700

    Account for edge case where user deleted leading separator.

commit 41196cc
Author: zixaphir <[email protected]>
Date:   Wed Aug 30 20:20:19 2023 -0700

    account for customizable extra network separators in remove code

    previous behavior only searched for leading spaces

commit f3d1631
Author: JaredTherriault <[email protected]>
Date:   Sun Aug 27 21:54:05 2023 -0700

    Offloading custom work

    -custom_statics works to do mass replace strings, intended for copy-pasting gen info from internet generations and replacing unsavory prompts with safer prompts for my own sanity
    -tried to implement this into generation_parameters_copypaste but it didn't work out this iteration, presumably because we return a string and the calling method is looking for an object type
    -updated webui-user.bat to set a custom temp directory (for disk space concerns) and to apply xformers (for generation speed)

    I probably won't be merging any of this work into the main repo since I don't want to mess with anyone else's prompts, this is just intended to keep my workspace safe from anything I don't want to see. Eventually this should be done in an extension which I could then publish, but I need to learn a lot more about the extension and callback systems in the main repo first. just uploading this to my fork for now so i don't lose the current progress.
  • Loading branch information
k1nos committed Oct 11, 2023
1 parent 22e1fb6 commit b72f882
Show file tree
Hide file tree
Showing 30 changed files with 341 additions and 116 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module.exports = {
create_submit_args: "readonly",
restart_reload: "readonly",
updateInput: "readonly",
onEdit: "readonly",
//extraNetworks.js
requestGet: "readonly",
popup: "readonly",
Expand Down
33 changes: 33 additions & 0 deletions extensions-builtin/Lora/lora_logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
import copy
import logging


class ColoredFormatter(logging.Formatter):
COLORS = {
"DEBUG": "\033[0;36m", # CYAN
"INFO": "\033[0;32m", # GREEN
"WARNING": "\033[0;33m", # YELLOW
"ERROR": "\033[0;31m", # RED
"CRITICAL": "\033[0;37;41m", # WHITE ON RED
"RESET": "\033[0m", # RESET COLOR
}

def format(self, record):
colored_record = copy.copy(record)
levelname = colored_record.levelname
seq = self.COLORS.get(levelname, self.COLORS["RESET"])
colored_record.levelname = f"{seq}{levelname}{self.COLORS['RESET']}"
return super().format(colored_record)


logger = logging.getLogger("lora")
logger.propagate = False


if not logger.handlers:
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(
ColoredFormatter("[%(name)s]-%(levelname)s: %(message)s")
)
logger.addHandler(handler)
1 change: 1 addition & 0 deletions extensions-builtin/Lora/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self, name, network_on_disk: NetworkOnDisk):
self.unet_multiplier = 1.0
self.dyn_dim = None
self.modules = {}
self.bundle_embeddings = {}
self.mtime = None

self.mentioned_name = None
Expand Down
69 changes: 69 additions & 0 deletions extensions-builtin/Lora/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
from typing import Union

from modules import shared, devices, sd_models, errors, scripts, sd_hijack
from modules.textual_inversion.textual_inversion import Embedding

from lora_logger import logger

module_types = [
network_lora.ModuleTypeLora(),
Expand Down Expand Up @@ -149,9 +152,19 @@ def load_network(name, network_on_disk):
is_sd2 = 'model_transformer_resblocks' in shared.sd_model.network_layer_mapping

matched_networks = {}
bundle_embeddings = {}

for key_network, weight in sd.items():
key_network_without_network_parts, network_part = key_network.split(".", 1)
if key_network_without_network_parts == "bundle_emb":
emb_name, vec_name = network_part.split(".", 1)
emb_dict = bundle_embeddings.get(emb_name, {})
if vec_name.split('.')[0] == 'string_to_param':
_, k2 = vec_name.split('.', 1)
emb_dict['string_to_param'] = {k2: weight}
else:
emb_dict[vec_name] = weight
bundle_embeddings[emb_name] = emb_dict

key = convert_diffusers_name_to_compvis(key_network_without_network_parts, is_sd2)
sd_module = shared.sd_model.network_layer_mapping.get(key, None)
Expand Down Expand Up @@ -195,6 +208,41 @@ def load_network(name, network_on_disk):

net.modules[key] = net_module

embeddings = {}
for emb_name, data in bundle_embeddings.items():
# textual inversion embeddings
if 'string_to_param' in data:
param_dict = data['string_to_param']
param_dict = getattr(param_dict, '_parameters', param_dict) # fix for torch 1.12.1 loading saved file from torch 1.11
assert len(param_dict) == 1, 'embedding file has multiple terms in it'
emb = next(iter(param_dict.items()))[1]
vec = emb.detach().to(devices.device, dtype=torch.float32)
shape = vec.shape[-1]
vectors = vec.shape[0]
elif type(data) == dict and 'clip_g' in data and 'clip_l' in data: # SDXL embedding
vec = {k: v.detach().to(devices.device, dtype=torch.float32) for k, v in data.items()}
shape = data['clip_g'].shape[-1] + data['clip_l'].shape[-1]
vectors = data['clip_g'].shape[0]
elif type(data) == dict and type(next(iter(data.values()))) == torch.Tensor: # diffuser concepts
assert len(data.keys()) == 1, 'embedding file has multiple terms in it'

emb = next(iter(data.values()))
if len(emb.shape) == 1:
emb = emb.unsqueeze(0)
vec = emb.detach().to(devices.device, dtype=torch.float32)
shape = vec.shape[-1]
vectors = vec.shape[0]
else:
raise Exception(f"Couldn't identify {emb_name} in lora: {name} as neither textual inversion embedding nor diffuser concept.")

embedding = Embedding(vec, emb_name)
embedding.vectors = vectors
embedding.shape = shape
embedding.loaded = None
embeddings[emb_name] = embedding

net.bundle_embeddings = embeddings

if keys_failed_to_match:
logging.debug(f"Network {network_on_disk.filename} didn't match keys: {keys_failed_to_match}")

Expand All @@ -210,11 +258,15 @@ def purge_networks_from_memory():


def load_networks(names, te_multipliers=None, unet_multipliers=None, dyn_dims=None):
emb_db = sd_hijack.model_hijack.embedding_db
already_loaded = {}

for net in loaded_networks:
if net.name in names:
already_loaded[net.name] = net
for emb_name, embedding in net.bundle_embeddings.items():
if embedding.loaded:
emb_db.register_embedding_by_name(None, shared.sd_model, emb_name)

loaded_networks.clear()

Expand Down Expand Up @@ -257,6 +309,21 @@ def load_networks(names, te_multipliers=None, unet_multipliers=None, dyn_dims=No
net.dyn_dim = dyn_dims[i] if dyn_dims else 1.0
loaded_networks.append(net)

for emb_name, embedding in net.bundle_embeddings.items():
if embedding.loaded is None and emb_name in emb_db.word_embeddings:
logger.warning(
f'Skip bundle embedding: "{emb_name}"'
' as it was already loaded from embeddings folder'
)
continue

embedding.loaded = False
if emb_db.expected_shape == -1 or emb_db.expected_shape == embedding.shape:
embedding.loaded = True
emb_db.register_embedding(embedding, shared.sd_model)
else:
emb_db.skipped_embeddings[name] = embedding

if failed_to_load_networks:
sd_hijack.model_hijack.comments.append("Networks not found: " + ", ".join(failed_to_load_networks))

Expand Down Expand Up @@ -418,6 +485,7 @@ def network_forward(module, input, original_forward):
def network_reset_cached_weight(self: Union[torch.nn.Conv2d, torch.nn.Linear]):
self.network_current_names = ()
self.network_weights_backup = None
self.network_bias_backup = None


def network_Linear_forward(self, input):
Expand Down Expand Up @@ -564,6 +632,7 @@ def infotext_pasted(infotext, params):
available_networks = {}
available_network_aliases = {}
loaded_networks = []
loaded_bundle_embeddings = {}
networks_in_memory = {}
available_network_hash_lookup = {}
forbidden_network_aliases = {}
Expand Down
2 changes: 1 addition & 1 deletion javascript/dragdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ window.addEventListener('paste', e => {
}

const firstFreeImageField = visibleImageFields
.filter(el => el.querySelector('input[type=file]'))?.[0];
.filter(el => !el.querySelector('img'))?.[0];

dropReplaceImage(
firstFreeImageField ?
Expand Down
22 changes: 8 additions & 14 deletions javascript/edit-attention.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,11 @@ function keyupEditAttention(event) {
const before = text.substring(0, selectionStart);
let beforeParen = before.lastIndexOf(OPEN);
if (beforeParen == -1) return false;
let beforeParenClose = before.lastIndexOf(CLOSE);
while (beforeParenClose !== -1 && beforeParenClose > beforeParen) {
beforeParen = before.lastIndexOf(OPEN, beforeParen - 1);
beforeParenClose = before.lastIndexOf(CLOSE, beforeParenClose - 1);
}

// Find closing parenthesis around current cursor
const after = text.substring(selectionStart);
let afterParen = after.indexOf(CLOSE);
if (afterParen == -1) return false;
let afterParenOpen = after.indexOf(OPEN);
while (afterParenOpen !== -1 && afterParen > afterParenOpen) {
afterParen = after.indexOf(CLOSE, afterParen + 1);
afterParenOpen = after.indexOf(OPEN, afterParenOpen + 1);
}
if (beforeParen === -1 || afterParen === -1) return false;

// Set the selection to the text between the parenthesis
const parenContent = text.substring(beforeParen + 1, selectionStart + afterParen);
Expand All @@ -46,9 +35,14 @@ function keyupEditAttention(event) {

function selectCurrentWord() {
if (selectionStart !== selectionEnd) return false;
const delimiters = opts.keyedit_delimiters + " \r\n\t";
const whitespace_delimiters = {"Tab": "\t", "Carriage Return": "\r", "Line Feed": "\n"};
let delimiters = opts.keyedit_delimiters;

for (let i of opts.keyedit_delimiters_whitespace) {
delimiters += whitespace_delimiters[i];
}

// seek backward until to find beggining
// seek backward to find beginning
while (!delimiters.includes(text[selectionStart - 1]) && selectionStart > 0) {
selectionStart--;
}
Expand Down Expand Up @@ -92,7 +86,7 @@ function keyupEditAttention(event) {
}

var end = text.slice(selectionEnd + 1).indexOf(closeCharacter) + 1;
var weight = parseFloat(text.slice(selectionEnd + 1, selectionEnd + 1 + end));
var weight = parseFloat(text.slice(selectionEnd + 1, selectionEnd + end));
if (isNaN(weight)) return;

weight += isPlus ? delta : -delta;
Expand Down
25 changes: 14 additions & 11 deletions javascript/extraNetworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ function setupExtraNetworks() {

onUiLoaded(setupExtraNetworks);

var re_extranet = /<([^:]+:[^:]+):[\d.]+>(.*)/;
var re_extranet_g = /\s+<([^:]+:[^:]+):[\d.]+>/g;
var re_extranet = /<([^:^>]+:[^:]+):[\d.]+>(.*)/;
var re_extranet_g = /<([^:^>]+:[^:]+):[\d.]+>/g;

function tryToRemoveExtraNetworkFromPrompt(textarea, text) {
var m = text.match(re_extranet);
var replaced = false;
var newTextareaText;
if (m) {
var extraTextBeforeNet = opts.extra_networks_add_text_separator;
var extraTextAfterNet = m[2];
var partToSearch = m[1];
var foundAtPosition = -1;
Expand All @@ -161,8 +162,13 @@ function tryToRemoveExtraNetworkFromPrompt(textarea, text) {
return found;
});

if (foundAtPosition >= 0 && newTextareaText.substr(foundAtPosition, extraTextAfterNet.length) == extraTextAfterNet) {
newTextareaText = newTextareaText.substr(0, foundAtPosition) + newTextareaText.substr(foundAtPosition + extraTextAfterNet.length);
if (foundAtPosition >= 0) {
if (newTextareaText.substr(foundAtPosition, extraTextAfterNet.length) == extraTextAfterNet) {
newTextareaText = newTextareaText.substr(0, foundAtPosition) + newTextareaText.substr(foundAtPosition + extraTextAfterNet.length);
}
if (newTextareaText.substr(foundAtPosition - extraTextBeforeNet.length, extraTextBeforeNet.length) == extraTextBeforeNet) {
newTextareaText = newTextareaText.substr(0, foundAtPosition - extraTextBeforeNet.length) + newTextareaText.substr(foundAtPosition);
}
}
} else {
newTextareaText = textarea.value.replaceAll(new RegExp(text, "g"), function(found) {
Expand Down Expand Up @@ -216,27 +222,24 @@ function extraNetworksSearchButton(tabs_id, event) {

var globalPopup = null;
var globalPopupInner = null;

function closePopup() {
if (!globalPopup) return;

globalPopup.style.display = "none";
}

function popup(contents) {
if (!globalPopup) {
globalPopup = document.createElement('div');
globalPopup.onclick = closePopup;
globalPopup.classList.add('global-popup');

var close = document.createElement('div');
close.classList.add('global-popup-close');
close.onclick = closePopup;
close.addEventListener("click", closePopup);
close.title = "Close";
globalPopup.appendChild(close);

globalPopupInner = document.createElement('div');
globalPopupInner.onclick = function(event) {
event.stopPropagation(); return false;
};
globalPopupInner.classList.add('global-popup-inner');
globalPopup.appendChild(globalPopupInner);

Expand Down Expand Up @@ -335,7 +338,7 @@ function extraNetworksEditUserMetadata(event, tabname, extraPage, cardName) {
function extraNetworksRefreshSingleCard(page, tabname, name) {
requestGet("./sd_extra_networks/get-single-card", {page: page, tabname: tabname, name: name}, function(data) {
if (data && data.html) {
var card = gradioApp().querySelector('.card[data-name=' + JSON.stringify(name) + ']'); // likely using the wrong stringify function
var card = gradioApp().querySelector(`#${tabname}_${page.replace(" ", "_")}_cards > .card[data-name="${name}"]`);

var newDiv = document.createElement('DIV');
newDiv.innerHTML = data.html;
Expand Down
46 changes: 46 additions & 0 deletions javascript/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
let settingsExcludeTabsFromShowAll = {
settings_tab_defaults: 1,
settings_tab_sysinfo: 1,
settings_tab_actions: 1,
settings_tab_licenses: 1,
};

function settingsShowAllTabs() {
gradioApp().querySelectorAll('#settings > div').forEach(function(elem) {
if (settingsExcludeTabsFromShowAll[elem.id]) return;

elem.style.display = "block";
});
}

function settingsShowOneTab() {
gradioApp().querySelector('#settings_show_one_page').click();
}

onUiLoaded(function() {
var edit = gradioApp().querySelector('#settings_search');
var editTextarea = gradioApp().querySelector('#settings_search > label > input');
var buttonShowAllPages = gradioApp().getElementById('settings_show_all_pages');
var settings_tabs = gradioApp().querySelector('#settings div');

onEdit('settingsSearch', editTextarea, 250, function() {
var searchText = (editTextarea.value || "").trim().toLowerCase();

gradioApp().querySelectorAll('#settings > div[id^=settings_] div[id^=column_settings_] > *').forEach(function(elem) {
var visible = elem.textContent.trim().toLowerCase().indexOf(searchText) != -1;
elem.style.display = visible ? "" : "none";
});

if (searchText != "") {
settingsShowAllTabs();
} else {
settingsShowOneTab();
}
});

settings_tabs.insertBefore(edit, settings_tabs.firstChild);
settings_tabs.appendChild(buttonShowAllPages);


buttonShowAllPages.addEventListener("click", settingsShowAllTabs);
});
Loading

0 comments on commit b72f882

Please sign in to comment.