aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGreendayle <Greendayle>2022-10-07 18:31:49 +0200
committerGreendayle <Greendayle>2022-10-07 18:31:49 +0200
commit537da7a304adff95fb2ed8337f7a764d08f67c46 (patch)
tree4a8b2c23d7c870314083d70e2d82edd9acbe677c /scripts
parent4320f386d9641c7c234589c4cb0c0c6cbeb156ad (diff)
parentf7c787eb7c295c27439f4fbdf78c26b8389560be (diff)
Merge branch 'master' into dev/deepdanbooru
Diffstat (limited to 'scripts')
-rw-r--r--scripts/img2imgalt.py3
-rw-r--r--scripts/outpainting_mk_2.py5
-rw-r--r--scripts/xy_grid.py18
3 files changed, 19 insertions, 7 deletions
diff --git a/scripts/img2imgalt.py b/scripts/img2imgalt.py
index 0ef137f7..f9894cb0 100644
--- a/scripts/img2imgalt.py
+++ b/scripts/img2imgalt.py
@@ -8,7 +8,6 @@ import gradio as gr
from modules import processing, shared, sd_samplers, prompt_parser
from modules.processing import Processed
-from modules.sd_samplers import samplers
from modules.shared import opts, cmd_opts, state
import torch
@@ -159,7 +158,7 @@ class Script(scripts.Script):
combined_noise = ((1 - randomness) * rec_noise + randomness * rand_noise) / ((randomness**2 + (1-randomness)**2) ** 0.5)
- sampler = samplers[p.sampler_index].constructor(p.sd_model)
+ sampler = sd_samplers.create_sampler_with_index(sd_samplers.samplers, p.sampler_index, p.sd_model)
sigmas = sampler.model_wrap.get_sigmas(p.steps)
diff --git a/scripts/outpainting_mk_2.py b/scripts/outpainting_mk_2.py
index 11613ca3..a6468e09 100644
--- a/scripts/outpainting_mk_2.py
+++ b/scripts/outpainting_mk_2.py
@@ -85,8 +85,11 @@ def get_matched_noise(_np_src_image, np_mask_rgb, noise_q=1, color_variation=0.0
src_dist = np.absolute(src_fft)
src_phase = src_fft / src_dist
+ # create a generator with a static seed to make outpainting deterministic / only follow global seed
+ rng = np.random.default_rng(0)
+
noise_window = _get_gaussian_window(width, height, mode=1) # start with simple gaussian noise
- noise_rgb = np.random.random_sample((width, height, num_channels))
+ noise_rgb = rng.random((width, height, num_channels))
noise_grey = (np.sum(noise_rgb, axis=2) / 3.)
noise_rgb *= color_variation # the colorfulness of the starting noise is blended to greyscale with a parameter
for c in range(num_channels):
diff --git a/scripts/xy_grid.py b/scripts/xy_grid.py
index 1237e754..c0c364df 100644
--- a/scripts/xy_grid.py
+++ b/scripts/xy_grid.py
@@ -1,8 +1,9 @@
from collections import namedtuple
from copy import copy
-from itertools import permutations
+from itertools import permutations, chain
import random
-
+import csv
+from io import StringIO
from PIL import Image
import numpy as np
@@ -76,6 +77,11 @@ def apply_checkpoint(p, x, xs):
modules.sd_models.reload_model_weights(shared.sd_model, info)
+def apply_hypernetwork(p, x, xs):
+ hn = shared.hypernetworks.get(x, None)
+ opts.data["sd_hypernetwork"] = hn.name if hn is not None else 'None'
+
+
def format_value_add_label(p, opt, x):
if type(x) == float:
x = round(x, 8)
@@ -121,6 +127,7 @@ axis_options = [
AxisOption("Prompt order", str_permutations, apply_order, format_value_join_list),
AxisOption("Sampler", str, apply_sampler, format_value),
AxisOption("Checkpoint name", str, apply_checkpoint, format_value),
+ AxisOption("Hypernetwork", str, apply_hypernetwork, format_value),
AxisOption("Sigma Churn", float, apply_field("s_churn"), format_value_add_label),
AxisOption("Sigma min", float, apply_field("s_tmin"), format_value_add_label),
AxisOption("Sigma max", float, apply_field("s_tmax"), format_value_add_label),
@@ -168,7 +175,6 @@ re_range_float = re.compile(r"\s*([+-]?\s*\d+(?:.\d*)?)\s*-\s*([+-]?\s*\d+(?:.\d
re_range_count = re.compile(r"\s*([+-]?\s*\d+)\s*-\s*([+-]?\s*\d+)(?:\s*\[(\d+)\s*\])?\s*")
re_range_count_float = re.compile(r"\s*([+-]?\s*\d+(?:.\d*)?)\s*-\s*([+-]?\s*\d+(?:.\d*)?)(?:\s*\[(\d+(?:.\d*)?)\s*\])?\s*")
-
class Script(scripts.Script):
def title(self):
return "X/Y plot"
@@ -193,11 +199,13 @@ class Script(scripts.Script):
modules.processing.fix_seed(p)
p.batch_size = 1
+ initial_hn = opts.sd_hypernetwork
+
def process_axis(opt, vals):
if opt.label == 'Nothing':
return [0]
- valslist = [x.strip() for x in vals.split(",")]
+ valslist = [x.strip() for x in chain.from_iterable(csv.reader(StringIO(vals)))]
if opt.type == int:
valslist_ext = []
@@ -300,4 +308,6 @@ class Script(scripts.Script):
# restore checkpoint in case it was changed by axes
modules.sd_models.reload_model_weights(shared.sd_model)
+ opts.data["sd_hypernetwork"] = initial_hn
+
return processed