Skip to content

Commit

Permalink
Merge pull request #3549 from vladmandic/dev
Browse files Browse the repository at this point in the history
refresh master
  • Loading branch information
vladmandic authored Nov 2, 2024
2 parents b48222c + bada60e commit 65ddc61
Show file tree
Hide file tree
Showing 28 changed files with 144 additions and 87 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
"getENActiveTab": "readonly",
"quickApplyStyle": "readonly",
"quickSaveStyle": "readonly",
"setupExtraNetworks": "readonly",
"showNetworks": "readonly",
// from python
"localization": "readonly",
// progressbar.js
Expand Down
21 changes: 14 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Change Log for SD.Next

## Update for 2024-11-01
## Update for 2024-11-02

Smaller release just 3 days after the last one, but with some important fixes and improvements.
Smaller release just few days after the last one, but with some important fixes and improvements.
This release can be considered an LTS release before we kick off the next round of major updates.

- XYZ grid:
- optional per-image time benchmark info
- UI:
- add additional [hotkeys](https://github.com/vladmandic/automatic/wiki/Hotkeys)
- Docs:
- add built-in [changelog](https://github.com/vladmandic/automatic/blob/master/CHANGELOG.md) search
since changelog is the best up-to-date source of info
Expand All @@ -21,13 +17,21 @@ This release can be considered an LTS release before we kick off the next round
- SD3: all-in-one safetensors
- *examples*: [large](https://civitai.com/models/882666/sd35-large-google-flan?modelVersionId=1003031), [medium](https://civitai.com/models/900327)
- *note*: enable *bnb* on-the-fly quantization for even bigger gains
- UI:
- add additional [hotkeys](https://github.com/vladmandic/automatic/wiki/Hotkeys)
- add show networks on startup setting
- better mapping of networks previews
- optimize networks display load
- XYZ grid:
- optional per-image time benchmark info
- CLI:
- refactor command line params
run `webui.sh`/`webui.bat` with `--help` to see all options
- Other:
- Repo: move screenshots to GH pages
- Update requirements
- Fixes:
- custom watermark add alphablending
- detailer min/max size as fractions of image size
- ipadapter load on-demand
- ipadapter face use correct yolo model
Expand All @@ -36,7 +40,10 @@ This release can be considered an LTS release before we kick off the next round
- fix diffusers load from folder
- fix lora enum logging on windows
- fix xyz grid with batch count
- move dowwloads of some auxillary models to hfcache instead of models folder
- fix vqa models ignoring hfcache folder setting
- fix network height in standard vs modern ui
- fix k-diff enum on startup
- move downloads of some auxillary models to hfcache instead of models folder

## Update for 2024-10-29

Expand Down
1 change: 1 addition & 0 deletions cli/image-watermark.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def watermark(params, file):

exif = get_exif(image)

wm = None
if params.command == 'read':
fn = params.input
wm = get_watermark(image, params)
Expand Down
Binary file modified html/logo-bg-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed html/logo-bg-10.jpg
Binary file not shown.
Binary file modified html/logo-bg-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html/logo-bg-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html/logo-bg-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html/logo-bg-5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html/logo-bg-6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html/logo-bg-7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html/logo-bg-8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified html/logo-bg-9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions html/previews.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"stabilityai--stable-diffusion-3-medium-diffusers": "models/Reference/stabilityai--stable-diffusion-3.jpg",
"stabilityai--stable-diffusion-3.5-medium": "models/Reference/stabilityai--stable-diffusion-3_5.jpg",
"stabilityai--stable-diffusion-3.5-large": "models/Reference/stabilityai--stable-diffusion-3_5.jpg",
"Disty0--FLUX.1-dev-qint8": "models/Reference/black-forest-labs--FLUX.1-dev.jpg",
"Disty0--FLUX.1-dev-qint4": "models/Reference/black-forest-labs--FLUX.1-dev.jpg",
"sayakpaul--flux.1-dev-nf4": "models/Reference/black-forest-labs--FLUX.1-dev.jpg",
"THUDM--CogVideoX-2b": "models/Reference/THUDM--CogView3-Plus-3B.jpg",
"THUDM--CogVideoX-5b": "models/Reference/THUDM--CogView3-Plus-3B.jpg",
"THUDM--CogVideoX-5b-I2V": "models/Reference/THUDM--CogView3-Plus-3B.jpg"
}
88 changes: 54 additions & 34 deletions javascript/extraNetworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ function setupExtraNetworksForTab(tabname) {
if (!tabs) return;

// buttons
const btnShow = gradioApp().getElementById(`${tabname}_extra_networks_btn`);
const btnRefresh = gradioApp().getElementById(`${tabname}_extra_refresh`);
const btnScan = gradioApp().getElementById(`${tabname}_extra_scan`);
const btnSave = gradioApp().getElementById(`${tabname}_extra_save`);
Expand Down Expand Up @@ -448,50 +449,69 @@ function setupExtraNetworksForTab(tabname) {

// en style
if (!en) return;
let lastView;
let heightInitialized = false;
const intersectionObserver = new IntersectionObserver((entries) => {
for (const el of Array.from(gradioApp().querySelectorAll('.extra-networks-page'))) {
el.style.height = `${window.opts.extra_networks_height}vh`;
el.parentElement.style.width = '-webkit-fill-available';
if (!heightInitialized) {
heightInitialized = true;
let h = 0;
const target = window.opts.extra_networks_card_cover === 'sidebar' ? 0 : window.opts.extra_networks_height;
if (window.opts.theme_type === 'Standard') h = target > 0 ? target : 55;
else h = target > 0 ? target : 87;
for (const el of Array.from(gradioApp().getElementById(`${tabname}_extra_tabs`).querySelectorAll('.extra-networks-page'))) {
if (h > 0) el.style.height = `${h}vh`;
el.parentElement.style.width = '-webkit-fill-available';
}
}
if (entries[0].intersectionRatio > 0) {
refreshENpage();
// sortExtraNetworks('fixed');
if (window.opts.extra_networks_card_cover === 'cover') {
en.style.transition = '';
en.style.zIndex = 100;
en.style.top = '13em';
en.style.position = 'absolute';
en.style.right = 'unset';
en.style.width = 'unset';
en.style.height = 'unset';
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = 'unset';
} else if (window.opts.extra_networks_card_cover === 'sidebar') {
en.style.zIndex = 100;
en.style.position = 'absolute';
en.style.right = '0';
en.style.top = '13em';
en.style.height = 'auto';
en.style.transition = 'width 0.3s ease';
en.style.width = `${window.opts.extra_networks_sidebar_width}vw`;
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = `${100 - 2 - window.opts.extra_networks_sidebar_width}vw`;
if (lastView !== entries[0].intersectionRatio > 0) {
lastView = entries[0].intersectionRatio > 0;
if (lastView) {
refreshENpage();
// sortExtraNetworks('fixed');
if (window.opts.extra_networks_card_cover === 'cover') {
en.style.position = 'absolute';
en.style.height = 'unset';
en.style.width = 'unset';
en.style.right = 'unset';
en.style.top = '13em';
en.style.transition = '';
en.style.zIndex = 100;
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = 'unset';
} else if (window.opts.extra_networks_card_cover === 'sidebar') {
en.style.position = 'absolute';
en.style.height = 'auto';
en.style.width = `${window.opts.extra_networks_sidebar_width}vw`;
en.style.right = '0';
en.style.top = '13em';
en.style.transition = 'width 0.3s ease';
en.style.zIndex = 100;
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = `${100 - 2 - window.opts.extra_networks_sidebar_width}vw`;
} else {
en.style.position = 'relative';
en.style.height = 'unset';
en.style.width = 'unset';
en.style.right = 'unset';
en.style.top = 0;
en.style.transition = '';
en.style.zIndex = 0;
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = 'unset';
}
} else {
en.style.transition = '';
en.style.zIndex = 0;
en.style.top = 0;
en.style.position = 'relative';
en.style.right = 'unset';
en.style.width = 'unset';
en.style.height = 'unset';
if (window.opts.extra_networks_card_cover === 'sidebar') en.style.width = 0;
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = 'unset';
}
} else {
if (window.opts.extra_networks_card_cover === 'sidebar') en.style.width = 0;
gradioApp().getElementById(`${tabname}_settings`).parentNode.style.width = 'unset';
}
});
intersectionObserver.observe(en); // monitor visibility
}

async function showNetworks() {
for (const tabname of ['txt2img', 'img2img', 'control']) {
if (window.opts.extra_networks_show) gradioApp().getElementById(`${tabname}_extra_networks_btn`).click();
}
log('showNetworks');
}

async function setupExtraNetworks() {
setupExtraNetworksForTab('txt2img');
setupExtraNetworksForTab('img2img');
Expand Down
4 changes: 2 additions & 2 deletions javascript/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const appStartTime = performance.now();
async function preloadImages() {
const dark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
const imagePromises = [];
const num = Math.floor(10 * Math.random());
const num = Math.floor(9.99 * Math.random());
const imageUrls = [
`file=html/logo-bg-${dark ? 'dark' : 'light'}.jpg`,
`file=html/logo-bg-${num}.jpg`,
Expand All @@ -27,7 +27,7 @@ async function preloadImages() {
async function createSplash() {
const dark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
log('createSplash', { theme: dark ? 'dark' : 'light' });
const num = Math.floor(11 * Math.random());
const num = Math.floor(9.99 * Math.random());
const splash = `
<div id="splash" class="splash" style="background: ${dark ? 'black' : 'white'}">
<div class="loading"><div class="loader"></div></div>
Expand Down
2 changes: 1 addition & 1 deletion javascript/sdnext.css
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ table.settings-value-table td { padding: 0.4em; border: 1px solid #ccc; max-widt
#extensions .date { opacity: 0.85; font-size: var(--text-sm); }

/* extra networks */
#txt2img_extra_networks, #img2img_extra_networks, #control_extra_networks { width: 0; }
.extra_networks_root { width: 0; position: absolute; height: auto; right: 0; top: 13em; z-index: 100; } /* default is sidebar view */
.extra-networks { background: var(--background-color); padding: var(--block-label-padding); }
.extra-networks > div { margin: 0; border-bottom: none !important; gap: 0.3em 0; }
.extra-networks .second-line { display: flex; width: -moz-available; width: -webkit-fill-available; gap: 0.3em; box-shadow: var(--input-shadow); }
Expand Down
1 change: 1 addition & 0 deletions javascript/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async function initStartup() {
removeSplash();

// post startup tasks that may take longer but are not critical
showNetworks();
setHints();
applyStyles();
initIndexDB();
Expand Down
12 changes: 10 additions & 2 deletions modules/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ def set_watermark(image, watermark):
wm_image = None
try:
wm_image = Image.open(shared.opts.image_watermark_image)
if wm_image.mode != 'RGBA':
wm_image = wm_image.convert('RGBA')
except Exception as e:
shared.log.warning(f'Set image watermark: fn="{shared.opts.image_watermark_image}" {e}')
if wm_image is not None:
Expand All @@ -392,8 +394,14 @@ def set_watermark(image, watermark):
try:
for x in range(wm_image.width):
for y in range(wm_image.height):
r, g, b, _a = wm_image.getpixel((x, y))
if not (r == 0 and g == 0 and b == 0):
rgba = wm_image.getpixel((x, y))
orig = image.getpixel((x+position[0], y+position[1]))
# alpha blend
a = rgba[3] / 255
r = int(rgba[0] * a + orig[0] * (1 - a))
g = int(rgba[1] * a + orig[1] * (1 - a))
b = int(rgba[2] * a + orig[2] * (1 - a))
if not a == 0:
image.putpixel((x+position[0], y+position[1]), (r, g, b))
shared.log.debug(f'Set image watermark: fn="{shared.opts.image_watermark_image}" image={wm_image} position={position}')
except Exception as e:
Expand Down
11 changes: 5 additions & 6 deletions modules/postprocess/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def __init__(self, cls: int, label: str, score: float, box: list[int], mask: Ima
self.box = box
self.mask = mask
self.item = item
self.size = size
self.width = width
self.height = height
self.args = args
Expand Down Expand Up @@ -127,17 +126,17 @@ def predict(
box = box.tolist()
mask_image = None
w, h = box[2] - box[0], box[3] - box[1]
size = w * h / (image.width * image.height)
min_size = (shared.opts.detailer_min_size if shared.opts.detailer_min_size > 0 else 0) * min(w, h)
max_size = (shared.opts.detailer_max_size if shared.opts.detailer_max_size > 0 else 1) * max(w, h)
if (min(w, h) > min_size) and (max(w, h) < max_size):
x_size, y_size = w/image.width, h/image.height
min_size = shared.opts.detailer_min_size if shared.opts.detailer_min_size > 0 and shared.opts.detailer_min_size < 1 else 0
max_size = shared.opts.detailer_max_size if shared.opts.detailer_max_size > 0 and shared.opts.detailer_max_size < 1 else 1
if x_size >= min_size and y_size >=min_size and x_size <= max_size and y_size <= max_size:
if mask:
mask_image = image.copy()
mask_image = Image.new('L', image.size, 0)
draw = ImageDraw.Draw(mask_image)
draw.rectangle(box, fill="white", outline=None, width=0)
cropped = image.crop(box)
result.append(YoloResult(cls=cls, label=label, score=round(score, 2), box=box, mask=mask_image, item=cropped, size=size, width=w, height=h, args=args))
result.append(YoloResult(cls=cls, label=label, score=round(score, 2), box=box, mask=mask_image, item=cropped, width=w, height=h, args=args))
if len(result) >= shared.opts.detailer_max:
break
return result
Expand Down
22 changes: 14 additions & 8 deletions modules/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,9 @@ def get_default_modes():
}))

options_templates.update(options_section(('extra_networks', "Networks"), {
"extra_networks_sep1": OptionInfo("<h2>Extra networks UI</h2>", "", gr.HTML),
"extra_networks": OptionInfo(["All"], "Networks", gr.Dropdown, lambda: {"multiselect":True, "choices": ['All'] + [en.title for en in extra_networks]}),
"extra_networks_sep1": OptionInfo("<h2>Networks UI</h2>", "", gr.HTML),
"extra_networks_show": OptionInfo(True, "UI show on startup"),
"extra_networks": OptionInfo(["All"], "Available networks", gr.Dropdown, lambda: {"multiselect":True, "choices": ['All'] + [en.title for en in extra_networks]}),
"extra_networks_sort": OptionInfo("Default", "Sort order", gr.Dropdown, {"choices": ['Default', 'Name [A-Z]', 'Name [Z-A]', 'Date [Newest]', 'Date [Oldest]', 'Size [Largest]', 'Size [Smallest]']}),
"extra_networks_view": OptionInfo("gallery", "UI view", gr.Radio, {"choices": ["gallery", "list"]}),
"extra_networks_card_cover": OptionInfo("sidebar", "UI position", gr.Radio, {"choices": ["cover", "inline", "sidebar"]}),
Expand All @@ -888,13 +889,18 @@ def get_default_modes():
"extra_networks_card_square": OptionInfo(True, "UI disable variable aspect ratio"),
"extra_networks_fetch": OptionInfo(True, "UI fetch network info on mouse-over"),
"extra_networks_card_fit": OptionInfo("cover", "UI image contain method", gr.Radio, {"choices": ["contain", "cover", "fill"], "visible": False}),
"extra_networks_sep2": OptionInfo("<h2>Extra networks general</h2>", "", gr.HTML),
"extra_network_reference": OptionInfo(False, "Use reference values when available", gr.Checkbox),
"extra_network_skip_indexing": OptionInfo(False, "Build info on first access", gr.Checkbox),
"extra_networks_default_multiplier": OptionInfo(1.0, "Default strength", gr.Slider, {"minimum": 0.0, "maximum": 2.0, "step": 0.01}),

"extra_networks_model_sep": OptionInfo("<h2>Models</h2>", "", gr.HTML),
"extra_network_reference": OptionInfo(False, "Use reference values when available", gr.Checkbox),
"extra_networks_embed_sep": OptionInfo("<h2>Embeddings</h2>", "", gr.HTML),
"diffusers_convert_embed": OptionInfo(False, "Auto-convert SD 1.5 embeddings to SDXL ", gr.Checkbox, {"visible": native}),
"extra_networks_sep3": OptionInfo("<h2>Extra networks settings</h2>", "", gr.HTML),
"extra_networks_styles_sep": OptionInfo("<h2>Styles</h2>", "", gr.HTML),
"extra_networks_styles": OptionInfo(True, "Show built-in styles"),
"extra_networks_wildcard_sep": OptionInfo("<h2>Wildcards</h2>", "", gr.HTML),
"wildcards_enabled": OptionInfo(True, "Enable file wildcards support"),
"extra_networks_lora_sep": OptionInfo("<h2>LoRA</h2>", "", gr.HTML),
"extra_networks_default_multiplier": OptionInfo(1.0, "Default strength", gr.Slider, {"minimum": 0.0, "maximum": 2.0, "step": 0.01}),
"lora_preferred_name": OptionInfo("filename", "LoRA preferred name", gr.Radio, {"choices": ["filename", "alias"]}),
"lora_add_hashes_to_infotext": OptionInfo(False, "LoRA add hash info"),
"lora_force_diffusers": OptionInfo(False if not cmd_opts.use_openvino else True, "LoRA force loading of all models using Diffusers"),
Expand All @@ -905,9 +911,9 @@ def get_default_modes():
"lora_quant": OptionInfo("NF4","LoRA precision in quantized models", gr.Radio, {"choices": ["NF4", "FP4"]}),
"lora_functional": OptionInfo(False, "Use Kohya method for handling multiple LoRA", gr.Checkbox, { "visible": False }),
"lora_load_gpu": OptionInfo(True if not cmd_opts.lowvram else False, "Load LoRA directly to GPU"),
"hypernetwork_enabled": OptionInfo(False, "Enable Hypernetwork support"),

"hypernetwork_enabled": OptionInfo(False, "Enable Hypernetwork support", gr.Checkbox, {"visible": False}),
"sd_hypernetwork": OptionInfo("None", "Add hypernetwork to prompt", gr.Dropdown, { "choices": ["None"], "visible": False }),
"wildcards_enabled": OptionInfo(True, "Enable file wildcards support"),
}))

options_templates.update(options_section((None, "Hidden options"), {
Expand Down
2 changes: 1 addition & 1 deletion modules/ui_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def create_ui(_blocks: gr.Blocks=None):
with gr.Row():
override_settings = ui_common.create_override_inputs('control')

with gr.Row(variant='compact', elem_id="control_extra_networks", visible=False) as extra_networks_ui:
with gr.Row(variant='compact', elem_id="control_extra_networks", elem_classes=["extra_networks_root"], visible=False) as extra_networks_ui:
from modules import timer, ui_extra_networks
extra_networks_ui = ui_extra_networks.create_ui(extra_networks_ui, btn_extra, 'control', skip_indexing=shared.opts.extra_network_skip_indexing)
timer.startup.record('ui-networks')
Expand Down
10 changes: 10 additions & 0 deletions modules/ui_extra_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
</div>
</div>
'''
preview_map = None


def init_api(app):
Expand Down Expand Up @@ -350,6 +351,9 @@ def find_preview(self, filename):
return self.link_preview(preview_file)

def update_all_previews(self, items):
global preview_map # pylint: disable=global-statement
if preview_map is None:
preview_map = shared.readfile('html/previews.json', silent=True)
t0 = time.time()
reference_path = os.path.abspath(os.path.join('models', 'Reference'))
possible_paths = list(set([os.path.dirname(item['filename']) for item in items] + [reference_path]))
Expand Down Expand Up @@ -378,8 +382,14 @@ def update_all_previews(self, items):
self.missing_thumbs.append(all_previews[file_idx])
item['preview'] = self.link_preview(all_previews[file_idx])
break
if item.get('preview', None) is None:
found = preview_map.get(base, None)
if found is not None:
item['preview'] = self.link_preview(found)
debug(f'EN mapped-preview: {item["name"]}={found}')
if item.get('preview', None) is None:
item['preview'] = self.link_preview('html/card-no-preview.png')
debug(f'EN missing-preview: {item["name"]}')
self.preview_time += time.time() - t0


Expand Down
Loading

0 comments on commit 65ddc61

Please sign in to comment.