Squashed commit of the following: commit 2c1e0168bb03a2cd625f2d4aca40eee0fdf7e4af Merge:2325c6c
31f2733
Author: Lincoln Stein <lincoln.stein@gmail.com> Date: Tue Oct 11 08:33:18 2022 -0400 Merge branch 'mkdocs-fixes' of https://github.com/mauwii/stable-diffusion into mauwii-mkdocs-fixes commit31f2733e89
Merge:d9d6d3a
a61a690
Author: Lincoln Stein <lincoln.stein@gmail.com> Date: Tue Oct 11 08:05:52 2022 -0400 Merge branch 'main' into mkdocs-fixes commitd9d6d3af3f
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 08:13:04 2022 +0200 some more minor, overseen fixes to IMG2IMG commit4ab5a2aeba
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 07:49:11 2022 +0200 add 4gotten alt-text to images commitf778bd9c0f
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 07:18:11 2022 +0200 update OTHER.md - fix codeblocks, add admonitions, embed graphic commita19f148a8e
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 06:51:29 2022 +0200 update IMG2IMG.md commitc1f1dfa714
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 06:10:25 2022 +0200 update EMBIGGEN.md - fix codeblocks - fix toc - use admonitions commit791e6c63ef
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 05:58:53 2022 +0200 better admonitions for CLI.md commite078025f00
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 05:50:32 2022 +0200 huge update to CLI.md way too many updates to list them all, including: - render keys for keyboard-shortcuts - quote commands and "unhide" parameter-values (like `<int>`, `<string>` - fix codeblocks - quote commands - quote filenames - use admonitions - .... commitbd98dd2307
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 04:49:57 2022 +0200 fix INPAINTING.md - fix numbered List - replace text key combos with actual rendered keyboard keys commit5392000335
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 04:30:11 2022 +0200 fix nubered list and codeblocks in INSTALL_WINDOWS commitffe9276f1e
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 04:12:56 2022 +0200 fix numbered list in INSTALL_LINUX.md also fix blank lines, codeblocks and admonition commit2c6a6a567f
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 03:51:03 2022 +0200 upgrade INSTALL_MAC.md: - use annotations and content-tabs yes, this looks ugly in repo afterwards, but plz also look at mkdocs: https://mauwii.github.io/stable-diffusion/installation/INSTALL_MAC/ commit8f6c544480
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 01:43:11 2022 +0200 comment out PR part in mkdocs-flow.yml commitb52c14a67f
Merge:97ebe58
a1b0b91
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 01:17:28 2022 +0200 Merge branch 'mkdocs-fixes' of github.com:mauwii/stable-diffusion into mkdocs-fixes commita1b0b91bb3
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:59:44 2022 +0200 fix conda env in codeblock commit5f9f9a266e
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:43:46 2022 +0200 fix 4gotten title in TEXTUAL_INVERSION commit8f025b034e
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:41:52 2022 +0200 quote repo_url and repo_name otherwise the version/stars/forks did not appear commit3a52b7deb3
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:39:54 2022 +0200 fix TEXTUAL_INVERSION headline to fit the others commit389b21f966
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:35:48 2022 +0200 fix SAMPLER_CONVERGENCE and add emoji commitf26fc79a18
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:32:04 2022 +0200 fix INSTALL_DOCKER.md: - fix title (Docker instead of "Before you begin") - add headline with Emoji - fix headlines to render toc correct commitcbc3520489
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:24:58 2022 +0200 add headline with emoji to INSTALL_MAC.md commit25f0614d66
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:21:01 2022 +0200 add log emoji to docs/CHANGELOG.md commit42005688fa
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:20:47 2022 +0200 use better fitting Icon for new Name commit0c65bad7f5
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:09:07 2022 +0200 add Headline with Emoji to WEB and POSTPROCESS commit1c1cf2692e
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 23:56:16 2022 +0200 update index.md: - remove unused template reference - make headline rendered bold and underlined, add (kind of) subtitle - update discord badge and link - update Quick links to look like in GH-Readme - also remove self reference to docs - add screenshot as in GH-Readme - add note pointing to issues tab - update path in command line to reflect new Repo Name commit0e29b0737e
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 23:23:10 2022 +0200 chng site_name to `Stable Diffusion Toolkit Docs` commitad8a60d992
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 23:00:02 2022 +0200 fix repo_url in mkdocs.yml commit234569d6b6
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 22:54:39 2022 +0200 fix link to upscaling in WEB.md and TOC - TOC fixed by adding `#` to every headline after `## Parting remarks` - add missing blank lines commit97c84ad824
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 22:25:32 2022 +0200 fix broken links in docs/CHANGELOG.md commitbce62b3a32
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 22:15:37 2022 +0200 add title to CHANGELOG.md to render TOC wo. `**` alternatively remove `**` around headline commit97ebe58b5b
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:59:44 2022 +0200 fix conda env in codeblock commit87ac217e43
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:43:46 2022 +0200 fix 4gotten title in TEXTUAL_INVERSION commit91439e8a52
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:41:52 2022 +0200 quote repo_url and repo_name otherwise the version/stars/forks did not appear commit8a632a9e8f
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:39:54 2022 +0200 fix TEXTUAL_INVERSION headline to fit the others commit7c8ffe2feb
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:35:48 2022 +0200 fix SAMPLER_CONVERGENCE and add emoji commite2e86d2d11
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:32:04 2022 +0200 fix INSTALL_DOCKER.md: - fix title (Docker instead of "Before you begin") - add headline with Emoji - fix headlines to render toc correct commit8b54c083fe
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:24:58 2022 +0200 add headline with emoji to INSTALL_MAC.md commit8d8a032434
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:21:01 2022 +0200 add log emoji to docs/CHANGELOG.md commit76519f6fa4
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:20:47 2022 +0200 use better fitting Icon for new Name commitaff0725533
Author: mauwii <Mauwii@outlook.de> Date: Tue Oct 11 00:09:07 2022 +0200 add Headline with Emoji to WEB and POSTPROCESS commit0f7898cbdd
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 23:56:16 2022 +0200 update index.md: - remove unused template reference - make headline rendered bold and underlined, add (kind of) subtitle - update discord badge and link - update Quick links to look like in GH-Readme - also remove self reference to docs - add screenshot as in GH-Readme - add note pointing to issues tab - update path in command line to reflect new Repo Name commitf4c04eadf8
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 23:23:10 2022 +0200 chng site_name to `Stable Diffusion Toolkit Docs` commit6e624827c0
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 23:00:02 2022 +0200 fix repo_url in mkdocs.yml commit158848dd7e
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 22:54:39 2022 +0200 fix link to upscaling in WEB.md and TOC - TOC fixed by adding `#` to every headline after `## Parting remarks` - add missing blank lines commit533736e135
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 22:29:46 2022 +0200 fix link to truncation_comparison.jpg in OTHER.md commitdd335142df
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 22:25:32 2022 +0200 fix broken links in docs/CHANGELOG.md commit374dd54f30
Author: mauwii <Mauwii@outlook.de> Date: Mon Oct 10 22:15:37 2022 +0200 add title to CHANGELOG.md to render TOC wo. `**` alternatively remove `**` around headline
6.4 KiB
title |
---|
Postprocessing |
:material-image-edit: Postprocessing
Intro
This extension provides the ability to restore faces and upscale images.
Face restoration and upscaling can be applied at the time you generate the images, or at any later time against a previously-generated PNG file, using the !fix command. Outpainting and outcropping can only be applied after the fact.
Face Fixing
The default face restoration module is GFPGAN. The default upscale is Real-ESRGAN. For an alternative face restoration module, see [CodeFormer Support] below.
As of version 1.14, environment.yaml will install the Real-ESRGAN package into the standard install location for python packages, and will put GFPGAN into a subdirectory of "src" in the InvokeAI directory. Upscaling with Real-ESRGAN should "just work" without further intervention. Simply pass the --upscale (-U) option on the invoke> command line, or indicate the desired scale on the popup in the Web GUI.
GFPGAN requires a series of downloadable model files to
work. These are loaded when you run scripts/preload_models.py
. If
GFPAN is failing with an error, please run the following from the
InvokeAI directory:
python scripts/preload_models.py
If you do not run this script in advance, the GFPGAN module will attempt to download the models files the first time you try to perform facial reconstruction.
Alternatively, if you have GFPGAN installed elsewhere, or if you are
using an earlier version of this package which asked you to install
GFPGAN in a sibling directory, you may use the --gfpgan_dir
argument
with invoke.py
to set a custom path to your GFPGAN directory. There
are other GFPGAN related boot arguments if you wish to customize
further.
Usage
You will now have access to two new prompt arguments.
Upscaling
-U : <upscaling_factor> <upscaling_strength>
The upscaling prompt argument takes two values. The first value is a scaling
factor and should be set to either 2
or 4
only. This will either scale the
image 2x or 4x respectively using different models.
You can set the scaling stength between 0
and 1.0
to control intensity of
the of the scaling. This is handy because AI upscalers generally tend to smooth
out texture details. If you wish to retain some of those for natural looking
results, we recommend using values between 0.5 to 0.8
.
If you do not explicitly specify an upscaling_strength, it will default to 0.75.
Face Restoration
-G : <gfpgan_strength>
This prompt argument controls the strength of the face restoration that is being
applied. Similar to upscaling, values between 0.5 to 0.8
are recommended.
You can use either one or both without any conflicts. In cases where you use both, the image will be first upscaled and then the face restoration process will be executed to ensure you get the highest quality facial features.
--save_orig
When you use either -U
or -G
, the final result you get is upscaled or face
modified. If you want to save the original Stable Diffusion generation, you can
use the -save_orig
prompt argument to save the original unaffected version
too.
Example Usage
invoke> superman dancing with a panda bear -U 2 0.6 -G 0.4
This also works with img2img:
invoke> a man wearing a pineapple hat -I path/to/your/file.png -U 2 0.5 -G 0.6
!!! note
GFPGAN and Real-ESRGAN are both memory intensive. In order to avoid crashes and memory overloads
during the Stable Diffusion process, these effects are applied after Stable Diffusion has completed
its work.
In single image generations, you will see the output right away but when you are using multiple
iterations, the images will first be generated and then upscaled and face restored after that
process is complete. While the image generation is taking place, you will still be able to preview
the base images.
If you wish to stop during the image generation but want to upscale or face
restore a particular generated image, pass it again with the same prompt and
generated seed along with the -U
and -G
prompt arguments to perform those
actions.
CodeFormer Support
This repo also allows you to perform face restoration using CodeFormer.
In order to setup CodeFormer to work, you need to download the models
like with GFPGAN. You can do this either by running
preload_models.py
or by manually downloading the model
file
and saving it to ldm/invoke/restoration/codeformer/weights
folder.
You can use -ft
prompt argument to swap between CodeFormer and the
default GFPGAN. The above mentioned -G
prompt argument will allow
you to control the strength of the restoration effect.
Usage:
The following command will perform face restoration with CodeFormer instead of the default gfpgan.
<prompt> -G 0.8 -ft codeformer
Other Options:
-cf
- cf or CodeFormer Fidelity takes values between0
and1
. 0 produces high quality results but low accuracy and 1 produces lower quality results but higher accuacy to your original face.
The following command will perform face restoration with CodeFormer. CodeFormer will output a result that is closely matching to the input face.
<prompt> -G 1.0 -ft codeformer -cf 0.9
The following command will perform face restoration with CodeFormer. CodeFormer will output a result that is the best restoration possible. This may deviate slightly from the original face. This is an excellent option to use in situations when there is very little facial data to work with.
<prompt> -G 1.0 -ft codeformer -cf 0.1
Fixing Previously-Generated Images
It is easy to apply face restoration and/or upscaling to any
previously-generated file. Just use the syntax !fix path/to/file.png <options>
. For example, to apply GFPGAN at strength 0.8 and upscale
2X for a file named ./outputs/img-samples/000044.2945021133.png
,
just run:
invoke> !fix ./outputs/img-samples/000044.2945021133.png -G 0.8 -U 2
A new file named 000044.2945021133.fixed.png
will be created in the output
directory. Note that the !fix
command does not replace the original file,
unlike the behavior at generate time.
Disabling:
If, for some reason, you do not wish to load the GFPGAN and/or ESRGAN libraries,
you can disable them on the invoke.py command line with the --no_restore
and
--no_upscale
options, respectively.