aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/codeformer_model.py6
-rw-r--r--modules/images.py52
-rw-r--r--modules/img2img.py1
-rw-r--r--modules/processing.py1
-rw-r--r--modules/shared.py8
-rw-r--r--requirements.txt2
-rw-r--r--requirements_versions.txt2
-rw-r--r--script.js5
-rw-r--r--style.css1
-rw-r--r--webui.bat6
10 files changed, 49 insertions, 35 deletions
diff --git a/modules/codeformer_model.py b/modules/codeformer_model.py
index 6cd29c83..21c704f7 100644
--- a/modules/codeformer_model.py
+++ b/modules/codeformer_model.py
@@ -56,13 +56,13 @@ def setup_codeformer():
self.net.to(shared.device)
return self.net, self.face_helper
- net = net_class(dim_embd=512, codebook_size=1024, n_head=8, n_layers=9, connect_list=['32', '64', '128', '256']).to(shared.device_codeformer)
+ net = net_class(dim_embd=512, codebook_size=1024, n_head=8, n_layers=9, connect_list=['32', '64', '128', '256']).to(devices.device_codeformer)
ckpt_path = load_file_from_url(url=pretrain_model_url, model_dir=os.path.join(path, 'weights/CodeFormer'), progress=True)
checkpoint = torch.load(ckpt_path)['params_ema']
net.load_state_dict(checkpoint)
net.eval()
- face_helper = FaceRestoreHelper(1, face_size=512, crop_ratio=(1, 1), det_model='retinaface_resnet50', save_ext='png', use_parse=True, device=shared.device_codeformer)
+ face_helper = FaceRestoreHelper(1, face_size=512, crop_ratio=(1, 1), det_model='retinaface_resnet50', save_ext='png', use_parse=True, device=devices.device_codeformer)
self.net = net
self.face_helper = face_helper
@@ -84,7 +84,7 @@ def setup_codeformer():
for idx, cropped_face in enumerate(self.face_helper.cropped_faces):
cropped_face_t = img2tensor(cropped_face / 255., bgr2rgb=True, float32=True)
normalize(cropped_face_t, (0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True)
- cropped_face_t = cropped_face_t.unsqueeze(0).to(shared.device_codeformer)
+ cropped_face_t = cropped_face_t.unsqueeze(0).to(devices.device_codeformer)
try:
with torch.no_grad():
diff --git a/modules/images.py b/modules/images.py
index a08b549a..ddd310a2 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -1,3 +1,4 @@
+import datetime
import math
import os
from collections import namedtuple
@@ -252,6 +253,31 @@ def sanitize_filename_part(text, replace_spaces=True):
return text.translate({ord(x): '' for x in invalid_filename_chars})[:128]
+def apply_filename_pattern(x, p, seed, prompt):
+ if seed is not None:
+ x = x.replace("[seed]", str(seed))
+ if prompt is not None:
+ x = x.replace("[prompt]", sanitize_filename_part(prompt)[:128])
+ x = x.replace("[prompt_spaces]", sanitize_filename_part(prompt, replace_spaces=False)[:128])
+ if "[prompt_words]" in x:
+ words = [x for x in re_nonletters.split(prompt or "") if len(x) > 0]
+ if len(words) == 0:
+ words = ["empty"]
+
+ x = x.replace("[prompt_words]", " ".join(words[0:8]).strip())
+ if p is not None:
+ x = x.replace("[steps]", str(p.steps))
+ x = x.replace("[cfg]", str(p.cfg_scale))
+ x = x.replace("[width]", str(p.width))
+ x = x.replace("[height]", str(p.height))
+ x = x.replace("[sampler]", sd_samplers.samplers[p.sampler_index].name)
+
+ x = x.replace("[model_hash]", shared.sd_model_hash)
+ x = x.replace("[date]", datetime.date.today().isoformat())
+
+ return x
+
+
def save_image(image, path, basename, seed=None, prompt=None, extension='png', info=None, short_filename=False, no_prompt=False, pnginfo_section_name='parameters', p=None, existing_info=None):
# would be better to add this as an argument in future, but will do for now
is_a_grid = basename != ""
@@ -259,26 +285,14 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
if short_filename or prompt is None or seed is None:
file_decoration = ""
elif opts.save_to_dirs:
- file_decoration = opts.samples_filename_format or "[seed]"
+ file_decoration = opts.samples_filename_pattern or "[seed]"
else:
- file_decoration = opts.samples_filename_format or "[seed]-[prompt_spaces]"
+ file_decoration = opts.samples_filename_pattern or "[seed]-[prompt_spaces]"
if file_decoration != "":
file_decoration = "-" + file_decoration.lower()
- if seed is not None:
- file_decoration = file_decoration.replace("[seed]", str(seed))
- if prompt is not None:
- file_decoration = file_decoration.replace("[prompt]", sanitize_filename_part(prompt)[:128])
- file_decoration = file_decoration.replace("[prompt_spaces]", sanitize_filename_part(prompt, replace_spaces=False)[:128])
- if p is not None:
- file_decoration = file_decoration.replace("[steps]", str(p.steps))
- file_decoration = file_decoration.replace("[cfg]", str(p.cfg_scale))
- file_decoration = file_decoration.replace("[width]", str(p.width))
- file_decoration = file_decoration.replace("[height]", str(p.height))
- file_decoration = file_decoration.replace("[sampler]", sd_samplers.samplers[p.sampler_index].name)
-
- file_decoration = file_decoration.replace("[model_hash]", shared.sd_model_hash)
+ file_decoration = apply_filename_pattern(file_decoration, p, seed, prompt)
if extension == 'png' and opts.enable_pnginfo and info is not None:
pnginfo = PngImagePlugin.PngInfo()
@@ -293,12 +307,8 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
save_to_dirs = (is_a_grid and opts.grid_save_to_dirs) or (not is_a_grid and opts.save_to_dirs)
- if save_to_dirs and not no_prompt:
- words = [x for x in re_nonletters.split(prompt or "") if len(x)>0]
- if len(words) == 0:
- words = ["empty"]
-
- dirname = " ".join(words[0:opts.save_to_dirs_prompt_len]).strip()
+ if save_to_dirs:
+ dirname = apply_filename_pattern(opts.directories_filename_pattern or "[prompt_words]", p, seed, prompt)
path = os.path.join(path, dirname)
os.makedirs(path, exist_ok=True)
diff --git a/modules/img2img.py b/modules/img2img.py
index 15e35093..e3109121 100644
--- a/modules/img2img.py
+++ b/modules/img2img.py
@@ -63,7 +63,6 @@ def img2img(prompt: str, negative_prompt: str, prompt_style: str, init_img, init
inpaint_full_res=inpaint_full_res,
inpainting_mask_invert=inpainting_mask_invert,
extra_generation_params={
- "Denoising strength": denoising_strength,
"Denoising strength change factor": (denoising_strength_change_factor if is_loopback else None)
}
)
diff --git a/modules/processing.py b/modules/processing.py
index 17b4a37b..92bf66f2 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -194,6 +194,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
"Variation seed": (None if p.subseed_strength == 0 else all_subseeds[index]),
"Variation seed strength": (None if p.subseed_strength == 0 else p.subseed_strength),
"Seed resize from": (None if p.seed_resize_from_w == 0 or p.seed_resize_from_h == 0 else f"{p.seed_resize_from_w}x{p.seed_resize_from_h}"),
+ "Denoising strength": getattr(p, 'denoising_strength', None),
}
if p.extra_generation_params is not None:
diff --git a/modules/shared.py b/modules/shared.py
index 8e07c9b1..891d7fb2 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -97,7 +97,10 @@ class Options:
data = None
hide_dirs = {"visible": False} if cmd_opts.hide_ui_dir_config else None
data_labels = {
- "samples_filename_format": OptionInfo("", "Samples filename format using following tags: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [sampler], [seed], [model_hash]. Leave blank for default."),
+ "samples_filename_pattern": OptionInfo("", "Images filename pattern"),
+ "save_to_dirs": OptionInfo(False, "Save images to a subdirectory"),
+ "grid_save_to_dirs": OptionInfo(False, "Save grids to subdirectory"),
+ "directories_filename_pattern": OptionInfo("", "Directory name pattern"),
"outdir_samples": OptionInfo("", "Output directory for images; if empty, defaults to two directories below", component_args=hide_dirs),
"outdir_txt2img_samples": OptionInfo("outputs/txt2img-images", 'Output directory for txt2img images', component_args=hide_dirs),
"outdir_img2img_samples": OptionInfo("outputs/img2img-images", 'Output directory for img2img images', component_args=hide_dirs),
@@ -105,9 +108,6 @@ class Options:
"outdir_grids": OptionInfo("", "Output directory for grids; if empty, defaults to two directories below", component_args=hide_dirs),
"outdir_txt2img_grids": OptionInfo("outputs/txt2img-grids", 'Output directory for txt2img grids', component_args=hide_dirs),
"outdir_img2img_grids": OptionInfo("outputs/img2img-grids", 'Output directory for img2img grids', component_args=hide_dirs),
- "save_to_dirs": OptionInfo(False, "When writing images, create a directory with name derived from the prompt"),
- "grid_save_to_dirs": OptionInfo(False, "When writing grids, create a directory with name derived from the prompt"),
- "save_to_dirs_prompt_len": OptionInfo(10, "When using above, how many words from prompt to put into directory name", gr.Slider, {"minimum": 1, "maximum": 32, "step": 1}),
"outdir_save": OptionInfo("log/images", "Directory for saving images using the Save button", component_args=hide_dirs),
"samples_save": OptionInfo(True, "Save indiviual samples"),
"samples_format": OptionInfo('png', 'File format for individual samples'),
diff --git a/requirements.txt b/requirements.txt
index 84c9bbd2..df7d2b8f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -14,6 +14,6 @@ scikit-image
fonts
font-roboto
git+https://github.com/crowsonkb/k-diffusion.git
-git+https://github.com/TencentARC/GFPGAN.git
+git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379
timm==0.4.12
fairscale==0.4.4
diff --git a/requirements_versions.txt b/requirements_versions.txt
index f3a4d2b8..c12d5712 100644
--- a/requirements_versions.txt
+++ b/requirements_versions.txt
@@ -1,4 +1,4 @@
-basicsr==1.3.5
+basicsr==1.4.2
gfpgan
gradio==3.3
numpy==1.23.3
diff --git a/script.js b/script.js
index ba2fa8a7..5c423908 100644
--- a/script.js
+++ b/script.js
@@ -1,3 +1,5 @@
+
+
titles = {
"Sampling steps": "How many times to improve the generated image iteratively; higher values take longer; very low values can produce bad results",
"Sampling method": "Which algorithm to use to produce the image",
@@ -53,6 +55,9 @@ titles = {
"Resize seed from width": "Make an attempt to produce a picture similar to what would have been produced with same seed at specified resolution",
"Interrogate": "Reconstruct frompt from existing image and put it into the prompt field.",
+
+ "Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [sampler], [seed], [model_hash], [prompt_words], [date]; leave empty for default.",
+ "Directory name pattern": "Use following tags to define how subdirectories for images and grids are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [sampler], [seed], [model_hash], [prompt_words], [date]; leave empty for default.",
}
function gradioApp(){
diff --git a/style.css b/style.css
index a57b2420..c1eb340b 100644
--- a/style.css
+++ b/style.css
@@ -115,6 +115,7 @@ fieldset span.text-gray-500, .gr-block.gr-box span.text-gray-500, label.block s
#settings .gr-panel div.flex-col div.justify-between div{
position: relative;
+ z-index: 200;
}
input[type="range"]{
diff --git a/webui.bat b/webui.bat
index b1e84b7a..509830c8 100644
--- a/webui.bat
+++ b/webui.bat
@@ -73,7 +73,7 @@ goto :show_stdout_stderr
%PYTHON% -c "import k_diffusion.sampling" >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :install_GFPGAN
echo Installing K-Diffusion...
-%PYTHON% -m pip install git+https://github.com/crowsonkb/k-diffusion.git --prefer-binary --only-binary=psutil >tmp/stdout.txt 2>tmp/stderr.txt
+%PYTHON% -m pip install git+https://github.com/crowsonkb/k-diffusion.git@1a0703dfb7d24d8806267c3e7ccc4caf67fd1331 --prefer-binary --only-binary=psutil >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :install_GFPGAN
goto :show_stdout_stderr
@@ -82,13 +82,11 @@ goto :show_stdout_stderr
%PYTHON% -c "import gfpgan" >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :install_reqs
echo Installing GFPGAN
-%PYTHON% -m pip install git+https://github.com/TencentARC/GFPGAN.git --prefer-binary >tmp/stdout.txt 2>tmp/stderr.txt
+%PYTHON% -m pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 --prefer-binary >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :install_reqs
goto :show_stdout_stderr
:install_reqs
-%PYTHON% -c "import omegaconf; import fonts; import timm" >tmp/stdout.txt 2>tmp/stderr.txt
-if %ERRORLEVEL% == 0 goto :make_dirs
echo Installing requirements...
%PYTHON% -m pip install -r %REQS_FILE% --prefer-binary >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :make_dirs