Unverified Commit 6f18c9b1 authored by missionfloyd's avatar missionfloyd Committed by GitHub
Browse files

Merge branch 'master' into extra-networks-toggle

parents 575c17a8 a0d07fb5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ jobs:
          cache-dependency-path: |
            **/requirements*txt
      - name: Run tests
        run: python launch.py --tests --no-half --disable-opt-split-attention --use-cpu all --skip-torch-cuda-test
        run: python launch.py --tests test --no-half --disable-opt-split-attention --use-cpu all --skip-torch-cuda-test
      - name: Upload main app stdout-stderr
        uses: actions/upload-artifact@v3
        if: always()
+21 −1
Original line number Diff line number Diff line
@@ -3,7 +3,9 @@ import os
import re
import torch

from modules import shared, devices, sd_models
from modules import shared, devices, sd_models, errors

metadata_tags_order = {"ss_sd_model_name": 1, "ss_resolution": 2, "ss_clip_skip": 3, "ss_num_train_images": 10, "ss_tag_frequency": 20}

re_digits = re.compile(r"\d+")
re_unet_down_blocks = re.compile(r"lora_unet_down_blocks_(\d+)_attentions_(\d+)_(.+)")
@@ -43,6 +45,23 @@ class LoraOnDisk:
    def __init__(self, name, filename):
        self.name = name
        self.filename = filename
        self.metadata = {}

        _, ext = os.path.splitext(filename)
        if ext.lower() == ".safetensors":
            try:
                self.metadata = sd_models.read_metadata_from_safetensors(filename)
            except Exception as e:
                errors.display(e, f"reading lora {filename}")

        if self.metadata:
            m = {}
            for k, v in sorted(self.metadata.items(), key=lambda x: metadata_tags_order.get(x[0], 999)):
                m[k] = v

            self.metadata = m

        self.ssmd_cover_images = self.metadata.pop('ssmd_cover_images', None)  # those are cover images and they are too big to display in UI as text


class LoraModule:
@@ -159,6 +178,7 @@ def load_loras(names, multipliers=None):


def lora_forward(module, input, res):
    input = devices.cond_cast_unet(input)
    if len(loaded_loras) == 0:
        return res

+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage):
                "search_term": self.search_terms_from_path(lora_on_disk.filename),
                "prompt": json.dumps(f"<lora:{name}:") + " + opts.extra_networks_default_multiplier + " + json.dumps(">"),
                "local_preview": f"{path}.{shared.opts.samples_format}",
                "metadata": json.dumps(lora_on_disk.metadata, indent=4) if lora_on_disk.metadata else None,
            }

    def allowed_directories_for_previews(self):
+4 −11
Original line number Diff line number Diff line
@@ -89,22 +89,15 @@ function checkBrackets(evt, textArea, counterElt) {
function setupBracketChecking(id_prompt, id_counter){
    var textarea = gradioApp().querySelector("#" + id_prompt + " > label > textarea");
    var counter = gradioApp().getElementById(id_counter)

    textarea.addEventListener("input", function(evt){
        checkBrackets(evt, textarea, counter)
    });
}

var shadowRootLoaded = setInterval(function() {
    var shadowRoot = document.querySelector('gradio-app').shadowRoot;
    if(! shadowRoot)  return false;

    var shadowTextArea = shadowRoot.querySelectorAll('#txt2img_prompt > label > textarea');
    if(shadowTextArea.length < 1)  return false;

    clearInterval(shadowRootLoaded);

onUiLoaded(function(){
    setupBracketChecking('txt2img_prompt', 'txt2img_token_counter')
    setupBracketChecking('txt2img_neg_prompt', 'txt2img_negative_token_counter')
    setupBracketChecking('img2img_prompt', 'imgimg_token_counter')
    setupBracketChecking('img2img_prompt', 'img2img_token_counter')
    setupBracketChecking('img2img_neg_prompt', 'img2img_negative_token_counter')
}, 1000);
})
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
<div class='card' {preview_html} onclick={card_clicked}>
<div class='card' style={style} onclick={card_clicked}>
	{metadata_button}

	<div class='actions'>
		<div class='additional'>
			<ul>
Loading