aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/processing.py10
-rw-r--r--requirements.txt1
-rw-r--r--requirements_versions.txt3
-rw-r--r--scripts/poor_mans_outpainting.py2
-rw-r--r--scripts/prompt_matrix.py2
-rw-r--r--scripts/xy_grid.py2
6 files changed, 12 insertions, 8 deletions
diff --git a/modules/processing.py b/modules/processing.py
index e615ffdc..78bc73b9 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -99,6 +99,10 @@ def create_random_tensors(shape, seeds):
return x
+def set_seed(seed):
+ return int(random.randrange(4294967294)) if seed is None or seed == -1 else seed
+
+
def process_images(p: StableDiffusionProcessing) -> Processed:
"""this is the main loop that both txt2img and img2img use; it calls func_init once inside all the scopes and func_sample once per batch"""
@@ -107,7 +111,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
assert p.prompt is not None
torch_gc()
- seed = int(random.randrange(4294967294)) if p.seed == -1 else p.seed
+ seed = set_seed(p.seed)
os.makedirs(p.outpath_samples, exist_ok=True)
os.makedirs(p.outpath_grids, exist_ok=True)
@@ -342,7 +346,9 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
self.paste_to = (x1, y1, x2-x1, y2-y1)
else:
self.image_mask = images.resize_image(self.resize_mode, self.image_mask, self.width, self.height)
- self.mask_for_overlay = self.image_mask
+ np_mask = np.array(self.image_mask)
+ np_mask = 255 - np.clip((255 - np_mask.astype(np.float)) * 2, 0, 255).astype(np.uint8)
+ self.mask_for_overlay = Image.fromarray(np_mask)
self.overlay_images = []
diff --git a/requirements.txt b/requirements.txt
index cb27daf5..c9e3f2fc 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -8,7 +8,6 @@ torch
transformers
omegaconf
pytorch_lightning
-basicsr
diffusers
invisible-watermark
git+https://github.com/crowsonkb/k-diffusion.git
diff --git a/requirements_versions.txt b/requirements_versions.txt
index 754b163c..177c6b58 100644
--- a/requirements_versions.txt
+++ b/requirements_versions.txt
@@ -1,4 +1,4 @@
-basicsr==1.4.1
+basicsr==1.3.5
gfpgan
gradio==3.2
numpy==1.22.0
@@ -8,4 +8,3 @@ torch
transformers==4.19.2
omegaconf==2.1.1
pytorch_lightning==1.7.2
-basicsr==1.3.5
diff --git a/scripts/poor_mans_outpainting.py b/scripts/poor_mans_outpainting.py
index d0f6a2fc..08171877 100644
--- a/scripts/poor_mans_outpainting.py
+++ b/scripts/poor_mans_outpainting.py
@@ -67,7 +67,7 @@ class Script(scripts.Script):
latent_mask = Image.new("L", (img.width, img.height), "white")
latent_draw = ImageDraw.Draw(latent_mask)
- latent_draw.rectangle((left + 1, up + 1, mask.width - right - 1, mask.height - down - 1), fill="black")
+ latent_draw.rectangle((left + left//2, up + up//2, mask.width - right - right//2, mask.height - down - down//2), fill="black")
processing.torch_gc()
diff --git a/scripts/prompt_matrix.py b/scripts/prompt_matrix.py
index 6d27df5a..a61d1183 100644
--- a/scripts/prompt_matrix.py
+++ b/scripts/prompt_matrix.py
@@ -50,7 +50,7 @@ class Script(scripts.Script):
return [put_at_start]
def run(self, p, put_at_start):
- seed = int(random.randrange(4294967294) if p.seed == -1 else p.seed)
+ seed = modules.processing.set_seed(p.seed)
original_prompt = p.prompt[0] if type(p.prompt) == list else p.prompt
diff --git a/scripts/xy_grid.py b/scripts/xy_grid.py
index 11be7a1b..df549298 100644
--- a/scripts/xy_grid.py
+++ b/scripts/xy_grid.py
@@ -108,7 +108,7 @@ class Script(scripts.Script):
return [x_type, x_values, y_type, y_values]
def run(self, p, x_type, x_values, y_type, y_values):
- p.seed = int(random.randrange(4294967294) if p.seed == -1 else p.seed)
+ p.seed = modules.processing.set_seed(p.seed)
p.batch_size = 1
p.batch_count = 1