fix minor bug, add info in swapper

main
Tran Xen 2 years ago
parent 9bb1c65db6
commit b7eebc619e

@ -16,6 +16,7 @@ gem "github-pages", "~> 228", group: :jekyll_plugins
group :jekyll_plugins do group :jekyll_plugins do
gem "webrick" gem "webrick"
gem 'jekyll-toc'
end end
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem

@ -190,6 +190,9 @@ GEM
jekyll-seo-tag (~> 2.0) jekyll-seo-tag (~> 2.0)
jekyll-titles-from-headings (0.5.3) jekyll-titles-from-headings (0.5.3)
jekyll (>= 3.3, < 5.0) jekyll (>= 3.3, < 5.0)
jekyll-toc (0.18.0)
jekyll (>= 3.9)
nokogiri (~> 1.12)
jekyll-watch (2.2.1) jekyll-watch (2.2.1)
listen (~> 3.0) listen (~> 3.0)
jemoji (0.12.0) jemoji (0.12.0)
@ -256,6 +259,7 @@ DEPENDENCIES
github-pages (~> 228) github-pages (~> 228)
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
jekyll (~> 3.9.3) jekyll (~> 3.9.3)
jekyll-toc
minima (~> 2.5.1) minima (~> 2.5.1)
tzinfo (>= 1, < 3) tzinfo (>= 1, < 3)
tzinfo-data tzinfo-data

@ -37,6 +37,9 @@ author:
minima: minima:
skin: dark skin: dark
plugins:
- jekyll-toc
# Exclude from processing. # Exclude from processing.
# The following items will not be processed, by default. # The following items will not be processed, by default.
# Any item listed under the `exclude:` key here will be automatically added to # Any item listed under the `exclude:` key here will be automatically added to

@ -0,0 +1,14 @@
---
layout: default
---
<article class="post">
<header class="post-header">
<h1 class="post-title">{{ page.title | escape }}</h1>
</header>
<div class="post-content">
{{ content | toc }}
</div>
</article>

@ -2,9 +2,10 @@
layout: page layout: page
title: Documentation title: Documentation
permalink: /doc/ permalink: /doc/
toc: true
--- ---
# Main Interface ## Main Interface
Here is the interface for FaceSwap Lab. It is available in the form of an accordion in both img2img and txt2img. Here is the interface for FaceSwap Lab. It is available in the form of an accordion in both img2img and txt2img.
@ -12,7 +13,7 @@ You can configure several units, each allowing you to replace a face. Here, 3 un
![](/assets/images/doc_mi.png) ![](/assets/images/doc_mi.png)
#### Face Unit ### Face Unit
The first thing to do is to activate the unit with **'enable'** if you want to use it. The first thing to do is to activate the unit with **'enable'** if you want to use it.
@ -25,7 +26,7 @@ Here are the main options for configuring a unit:
**You must always have at least one reference face OR a checkpoint. If both are selected, the checkpoint will be used and the reference ignored.** **You must always have at least one reference face OR a checkpoint. If both are selected, the checkpoint will be used and the reference ignored.**
#### Similarity ### Similarity
Always check for errors in the SD console. In particular, the absence of a reference face or a checkpoint can trigger errors. Always check for errors in the SD console. In particular, the absence of a reference face or a checkpoint can trigger errors.
@ -37,7 +38,7 @@ Always check for errors in the SD console. In particular, the absence of a refer
+ **Same gender:** the gender of the source face will be determined and only faces of the same gender will be considered. + **Same gender:** the gender of the source face will be determined and only faces of the same gender will be considered.
+ **Sort by size:** faces will be sorted from largest to smallest. + **Sort by size:** faces will be sorted from largest to smallest.
#### Pre-Inpainting : ### Pre-Inpainting
This part is applied BEFORE face swapping and only on matching faces. This part is applied BEFORE face swapping and only on matching faces.
@ -47,7 +48,7 @@ You can use a specific model for the replacement, different from the model used
For inpainting to be active, denoising must be greater than 0 and the Inpainting When option must be set to: For inpainting to be active, denoising must be greater than 0 and the Inpainting When option must be set to:
#### Post-Processing & Advanced Masks Options : (upscaled inswapper) ### Post-Processing & Advanced Masks Options : (upscaled inswapper)
By default, these settings are disabled, but you can use the global settings to modify the default behavior. These options are called "Default Upscaled swapper..." By default, these settings are disabled, but you can use the global settings to modify the default behavior. These options are called "Default Upscaled swapper..."
@ -65,7 +66,7 @@ The upscaled inswapper is disabled by default. It can be enabled in the sd optio
+ **improved mask:** The segmentation mask for the upscaled swapper is designed to avoid the square mask and prevent degradation of the non-face parts of the image. It is based on the Codeformer implementation. If "Use improved segmented mask (use pastenet to mask only the face)" and "upscaled inswapper" are checked in the settings, the mask will only cover the face, and will not be squared. However, depending on the image, this might introduce different types of problems such as artifacts on the border of the face. + **improved mask:** The segmentation mask for the upscaled swapper is designed to avoid the square mask and prevent degradation of the non-face parts of the image. It is based on the Codeformer implementation. If "Use improved segmented mask (use pastenet to mask only the face)" and "upscaled inswapper" are checked in the settings, the mask will only cover the face, and will not be squared. However, depending on the image, this might introduce different types of problems such as artifacts on the border of the face.
+ **erosion factor:** it is possible to adjust the mask erosion parameters using the erosion settings. The higher this setting is, the more the mask is reduced. + **erosion factor:** it is possible to adjust the mask erosion parameters using the erosion settings. The higher this setting is, the more the mask is reduced.
#### Post-Inpainting : ### Post-Inpainting
This part is applied AFTER face swapping and only on matching faces. This part is applied AFTER face swapping and only on matching faces.
@ -122,7 +123,7 @@ The checkpoint can then be used in the main interface (use refresh button)
## Processing order: ## Processing order
The extension is activated after all other extensions have been processed. During the execution, several steps take place. The extension is activated after all other extensions have been processed. During the execution, several steps take place.
@ -157,6 +158,16 @@ The API is documented in the FaceSwapLab tags in the http://localhost:7860/docs
You don't have to use the api_utils.py file and pydantic types, but it can save time. You don't have to use the api_utils.py file and pydantic types, but it can save time.
## Experimental GPU support
In Version 1.2.1, the ability to use the GPU has been added, a setting that can be configured in SD at startup. Currently, this feature is only supported on Windows and Linux, as the necessary dependencies for Mac have not been included.
The `--faceswaplab_gpu` option in SD can be added to the args in webui-user.sh or webui-user.bat.
The model stays loaded in VRAM and won't be unloaded after each use. As of now, I don't know a straightforward way to handle this, so it will occupy space continuously. If your system's VRAM is limited, enabling this option might not be advisable.
A change has also been made that could lead to some ripple effects. Previously, detection parameters such as det_size and det_thresh were automatically adjusted when a second model was loaded. This is no longer possible, so these parameters have been moved to the global settings to enable face detection.
## Settings ## Settings
You can change the program's default behavior in your webui's global settings (FaceSwapLab section in settings). This is particularly useful if you want to have default options for inpainting or for post-processsing, for example. You can change the program's default behavior in your webui's global settings (FaceSwapLab section in settings). This is particularly useful if you want to have default options for inpainting or for post-processsing, for example.
@ -164,3 +175,11 @@ You can change the program's default behavior in your webui's global settings (F
The interface must be restarted to take the changes into account. Sometimes you have to reboot the entire webui server. The interface must be restarted to take the changes into account. Sometimes you have to reboot the entire webui server.
There may be display bugs on some radio buttons that may not display the value (Codeformer might look disabled for instance). Check the logs to ensure that the transformation has been applied. There may be display bugs on some radio buttons that may not display the value (Codeformer might look disabled for instance). Check the logs to ensure that the transformation has been applied.
### det_size and det_thresh (detection accuracy and performances)
V1.2.1 : A change has been made that could lead to some ripple effects. Previously, detection parameters such as det_size and det_thresh were automatically adjusted when a second model was loaded. This is no longer possible, so these parameters have been moved to the global settings to enable face detection.
The `det_size` parameter defines the size of the detection area, controlling the spatial resolution at which faces are detected within an image. A larger detection size might capture more facial details, enhancing accuracy but potentially impacting processing speed. Conversely, the `det_thresh` parameter represents the detection threshold, serving as a sensitivity control for face detection. A higher threshold value leads to more conservative detection, capturing only the most prominent faces, while a lower threshold might detect more faces but could also result in more false positives.
It has been observed that a det_size value of 320 is more effective at detecting large faces. If there are issues with detecting large faces, switching to this value is recommended, though it might result in a loss of some quality.

@ -2,6 +2,7 @@
layout: page layout: page
title: FAQ title: FAQ
permalink: /faq/ permalink: /faq/
toc: true
--- ---
Our issue tracker often contains requests that may originate from a misunderstanding of the software's functionality. We aim to address these queries; however, due to time constraints, we may not be able to respond to each request individually. This FAQ section serves as a preliminary source of information for commonly raised concerns. We recommend reviewing these before submitting an issue. Our issue tracker often contains requests that may originate from a misunderstanding of the software's functionality. We aim to address these queries; however, due to time constraints, we may not be able to respond to each request individually. This FAQ section serves as a preliminary source of information for commonly raised concerns. We recommend reviewing these before submitting an issue.
@ -71,6 +72,16 @@ The quality of results is inherently tied to the capabilities of the model and c
Consider this extension as a low-cost alternative to more sophisticated tools like Lora, or as an addition to such tools. It's important to **maintain realistic expectations of the results** provided by this extension. Consider this extension as a low-cost alternative to more sophisticated tools like Lora, or as an addition to such tools. It's important to **maintain realistic expectations of the results** provided by this extension.
#### Why is a face not detected?
Face detection might be influenced by various factors and settings, particularly the det_size and det_thresh parameters. Here's how these could affect detection:
+ Detection Size (det_size): If the detection size is set too small, it may not capture large faces adequately. A value of 320 has been found to be more effective for detecting large faces, though it might result in a loss of some quality.
+ Detection Threshold (det_thresh): If the threshold is set too high, it can make the detection more conservative, capturing only the most prominent faces. A lower threshold might detect more faces but could also result in more false positives.
If a face is not being detected, adjusting these parameters might solve the issue. Try increasing the det_size if large faces are the problem, or experiment with different det_thresh values to find the balance that works best for your specific case.
#### Issue: Incorrect Gender Detection #### Issue: Incorrect Gender Detection
@ -78,11 +89,7 @@ The gender detection functionality is handled by the underlying analysis model.
#### Why isn't GPU support included? #### Why isn't GPU support included?
While implementing GPU support may seem straightforward, simply requiring a modification to the onnxruntime implementation and a change in providers in the swapper, there are reasons we haven't included it as a standard option. GPU is supported via an option see [documentation](../doc/). This is expermental, use it carefully.
The primary consideration is the substantial VRAM usage of the SD models. Integrating the model on the GPU doesn't result in significant performance gains with the current state of the software. Moreover, the GPU support becomes truly beneficial when processing large numbers of frames or video. However, our experience indicates that this tends to cause more issues than it resolves.
Consequently, requests for GPU support as a standard feature will not be considered.
#### What is the 'Upscaled Inswapper' Option in SD FaceSwapLab? #### What is the 'Upscaled Inswapper' Option in SD FaceSwapLab?

@ -8,6 +8,8 @@ permalink: /install/
The extension runs mainly on the CPU to avoid the use of VRAM. However, it is recommended to follow the specifications recommended by sd/a1111 with regard to prerequisites. At the time of writing, a version of python lower than 11 is preferable (even if it works with python 3.11, model loading and performance may fall short of expectations). The extension runs mainly on the CPU to avoid the use of VRAM. However, it is recommended to follow the specifications recommended by sd/a1111 with regard to prerequisites. At the time of writing, a version of python lower than 11 is preferable (even if it works with python 3.11, model loading and performance may fall short of expectations).
Older versions of gradio dont work well with the extension. See this bug report : https://github.com/glucauze/sd-webui-faceswaplab/issues/5. It has been tested on 3.32.0
### Windows-User : Visual Studio ! Don't neglect this ! ### Windows-User : Visual Studio ! Don't neglect this !
Before beginning the installation process, if you are using Windows, you need to install this requirement: Before beginning the installation process, if you are using Windows, you need to install this requirement:

@ -40,9 +40,9 @@ from scripts.faceswaplab_inpainting.i2i_pp import img2img_diffusion
from modules import shared from modules import shared
use_gpu = getattr(shared.cmd_opts, "faceswaplab_gpu", False) USE_GPU = getattr(shared.cmd_opts, "faceswaplab_gpu", False)
if use_gpu and sys.platform != "darwin": if USE_GPU and sys.platform != "darwin":
providers = [ providers = [
"TensorrtExecutionProvider", "TensorrtExecutionProvider",
"CUDAExecutionProvider", "CUDAExecutionProvider",
@ -283,7 +283,7 @@ def getAnalysisModel(
os.makedirs(faceswaplab_globals.ANALYZER_DIR) os.makedirs(faceswaplab_globals.ANALYZER_DIR)
logger.info( logger.info(
f"Load analysis model det_size={det_size}, det_thresh={det_thresh}, will take some time. (> 30s)" f"Load analysis model det_size={det_size}, det_thresh={det_thresh}, gpu={USE_GPU}, providers = {providers}, will take some time. (> 30s)"
) )
# Initialize the analysis model with the specified name and providers # Initialize the analysis model with the specified name and providers

@ -195,7 +195,7 @@ class UpscaledINSwapper(INSwapper):
logger.info("*" * 80) logger.info("*" * 80)
logger.info(f"Inswapper") logger.info(f"Inswapper")
if options.upscaler_name: if options.upscaler_name and options.upscaler_name != "None":
# Upscale original image # Upscale original image
k = 4 k = 4
aimg, M = face_align.norm_crop2( aimg, M = face_align.norm_crop2(

Loading…
Cancel
Save