From d8e300b202e54199d3dc63468a89f16a048fcfba Mon Sep 17 00:00:00 2001 From: Gourieff <777@lovemet.ru> Date: Tue, 19 Dec 2023 14:54:23 +0700 Subject: [PATCH] UPDATE: Enable like A1111-1.7.0; GFPGAN loading + UPDATE: Troubleshooting Sec. (Insightface whl installation) --- README.md | 10 +++++----- README_RU.md | 10 +++++----- scripts/reactor_faceswap.py | 15 +++++++++------ scripts/reactor_swapper.py | 9 +++++---- scripts/reactor_version.py | 2 +- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 4e06349..53dcc46 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ logo - ![Version](https://img.shields.io/badge/version-0.6.0_alpha2-lightgreen?style=for-the-badge&labelColor=darkgreen) + ![Version](https://img.shields.io/badge/version-0.6.0_alpha3-lightgreen?style=for-the-badge&labelColor=darkgreen) Support Me on Boosty @@ -257,10 +257,10 @@ If this method doesn't help - there is some other extension that has a wrong ver ### **VIII. (For Windows users) If you still cannot build Insightface for some reasons or just don't want to install Visual Studio or VS C++ Build Tools - do the following:** 1. Close (stop) your SD WebUI Server if it's running -2. Download and put [prebuilt Insightface package](https://github.com/Gourieff/sd-webui-reactor/raw/main/example/insightface-0.7.3-cp310-cp310-win_amd64.whl) into the stable-diffusion-webui (or SD.Next) root folder (where you have "webui-user.bat" file) -3. From stable-diffusion-webui (or SD.Next) root folder run CMD and `.\venv\Scripts\activate` -4. Then update your PIP: `python -m pip install -U pip` -5. Then install Insightface: `pip install insightface-0.7.3-cp310-cp310-win_amd64.whl` +2. Download and put [prebuilt Insightface package](https://github.com/Gourieff/sd-webui-reactor/raw/main/example/insightface-0.7.3-cp310-cp310-win_amd64.whl) into the stable-diffusion-webui (or SD.Next) root folder where you have "webui-user.bat" file or (A1111 Portable) "run.bat" +3. From stable-diffusion-webui (or SD.Next) root folder run CMD and `.\venv\Scripts\activate`
OR
(A1111 Portable) Run CMD +4. Then update your PIP: `python -m pip install -U pip`
OR
(A1111 Portable)`system\python\python.exe -m pip install -U pip` +5. Then install Insightface: `pip install insightface-0.7.3-cp310-cp310-win_amd64.whl`
OR
(A1111 Portable)`system\python\python.exe -m pip install insightface-0.7.3-cp310-cp310-win_amd64.whl` 6. Enjoy! ### **IX. 07-August-23 Update problem** diff --git a/README_RU.md b/README_RU.md index a1ba1f0..77ed941 100644 --- a/README_RU.md +++ b/README_RU.md @@ -2,7 +2,7 @@ logo - ![Version](https://img.shields.io/badge/версия-0.6.0_alpha2-lightgreen?style=for-the-badge&labelColor=darkgreen) + ![Version](https://img.shields.io/badge/версия-0.6.0_alpha3-lightgreen?style=for-the-badge&labelColor=darkgreen)
Поддержать проект на Boosty @@ -264,10 +264,10 @@ Inpainting также работает, но замена лица происх ### **VIII. (Для пользователей Windows) Если вы до сих пор не можете установить пакет Insightface по каким-то причинам или же просто не желаете устанавливать Visual Studio или VS C++ Build Tools - сделайте следующее:** 1. Закройте (остановите) SD WebUI Сервер, если он запущен -2. Скачайте готовый [пакет Insightface](https://github.com/Gourieff/sd-webui-reactor/raw/main/example/insightface-0.7.3-cp310-cp310-win_amd64.whl) и сохраните его в корневую директорию stable-diffusion-webui (или SD.Next) - туда, где лежит файл "webui-user.bat" -3. Из корневой директории откройте Консоль (CMD) и выполните `.\venv\Scripts\activate` -4. Обновите PIP: `python -m pip install -U pip` -5. Затем установите Insightface: `pip install insightface-0.7.3-cp310-cp310-win_amd64.whl` +2. Скачайте готовый [пакет Insightface](https://github.com/Gourieff/sd-webui-reactor/raw/main/example/insightface-0.7.3-cp310-cp310-win_amd64.whl) и сохраните его в корневую директорию stable-diffusion-webui (или SD.Next) - туда, где лежит файл "webui-user.bat" или (A1111 Portable) "run.bat" +3. Из корневой директории откройте Консоль (CMD) и выполните `.\venv\Scripts\activate`
ИЛИ
(A1111 Portable) Откройте Консоль (CMD) +4. Обновите PIP: `python -m pip install -U pip`
ИЛИ
(A1111 Portable)`system\python\python.exe -m pip install -U pip` +5. Затем установите Insightface: `pip install insightface-0.7.3-cp310-cp310-win_amd64.whl`
ИЛИ
(A1111 Portable)`system\python\python.exe -m pip install insightface-0.7.3-cp310-cp310-win_amd64.whl` 6. Готово! ### **IX. Ошибка обновления 07-Август-23** diff --git a/scripts/reactor_faceswap.py b/scripts/reactor_faceswap.py index 8812a4f..783c68c 100644 --- a/scripts/reactor_faceswap.py +++ b/scripts/reactor_faceswap.py @@ -6,7 +6,7 @@ from typing import List import modules.scripts as scripts from modules.upscaler import Upscaler, UpscalerData -from modules import scripts, shared, images, scripts_postprocessing +from modules import scripts, shared, images, scripts_postprocessing, ui_components from modules.processing import ( Processed, StableDiffusionProcessing, @@ -40,7 +40,8 @@ class FaceSwapScript(scripts.Script): return scripts.AlwaysVisible def ui(self, is_img2img): - with gr.Accordion(f"{app_title}", open=False): + with ui_components.InputAccordion(False, label=f"{app_title}") as enable: + # with gr.Accordion(f"{app_title}", open=False): # def on_files_upload_uncheck_so(selected: bool): # global SAVE_ORIGINAL @@ -50,8 +51,8 @@ class FaceSwapScript(scripts.Script): # clear_faces_list() # return gr.Checkbox.update(value=SAVE_ORIGINAL,visible=True) - enable = gr.Checkbox(False, label="Enable", info=f"The Fast and Simple FaceSwap Extension - {version_flag}") - gr.Markdown("
") + # enable = gr.Checkbox(False, label="Enable", info=f"The Fast and Simple FaceSwap Extension - {version_flag}") + gr.Markdown(f"The Fast and Simple FaceSwap Extension - {version_flag}") # TAB MAIN msgs: dict = { @@ -405,9 +406,11 @@ class FaceSwapScriptExtras(scripts_postprocessing.ScriptPostprocessing): order = 20000 def ui(self): - with gr.Accordion(f"{app_title}", open=False): + with ui_components.InputAccordion(False, label=f"{app_title}") as enable: + # with gr.Accordion(f"{app_title}", open=False): - enable = gr.Checkbox(False, label="Enable", info=f"The Fast and Simple FaceSwap Extension - {version_flag}") + # enable = gr.Checkbox(False, label="Enable", info=f"The Fast and Simple FaceSwap Extension - {version_flag}") + gr.Markdown(f"The Fast and Simple FaceSwap Extension - {version_flag}") # TAB MAIN msgs: dict = { diff --git a/scripts/reactor_swapper.py b/scripts/reactor_swapper.py index 75f44af..0f70bb2 100644 --- a/scripts/reactor_swapper.py +++ b/scripts/reactor_swapper.py @@ -23,9 +23,9 @@ from scripts.console_log_patch import apply_logging_patch from modules.face_restoration import FaceRestoration try: # A1111 - from modules import codeformer_model + from modules import codeformer_model, gfpgan_model except: # SD.Next - from modules.postprocess import codeformer_model + from modules.postprocess import codeformer_model, gfpgan_model from modules.upscaler import UpscalerData from modules.shared import state from scripts.reactor_logger import logger @@ -142,8 +142,9 @@ def restore_face(image: Image, enhancement_options: EnhancementOptions): numpy_image = codeformer_model.codeformer.restore( numpy_image, w=enhancement_options.codeformer_weight ) - else: - numpy_image = enhancement_options.face_restorer.restore(numpy_image) + else: # GFPGAN: + numpy_image = gfpgan_model.gfpgan_fix_faces(numpy_image) + # numpy_image = enhancement_options.face_restorer.restore(numpy_image) restored_image = Image.fromarray(numpy_image) result_image = Image.blend( original_image, restored_image, enhancement_options.restorer_visibility diff --git a/scripts/reactor_version.py b/scripts/reactor_version.py index 6a8d6fb..f590633 100644 --- a/scripts/reactor_version.py +++ b/scripts/reactor_version.py @@ -1,5 +1,5 @@ app_title = "ReActor" -version_flag = "v0.6.0-a2" +version_flag = "v0.6.0-a3" from scripts.reactor_logger import logger, get_Run, set_Run