Skip to content

Commit

Permalink
UPD+FIX: face_boost has no False after disconnect Node
Browse files Browse the repository at this point in the history
+Var renamed
+VersionUP (0.5.1 alpha5)
  • Loading branch information
Gourieff committed Jul 3, 2024
1 parent a48fbf5 commit 506c6cc
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_EN.png?raw=true" alt="logo" width="180px"/>

![Version](https://img.shields.io/badge/node_version-0.5.1_alpha4-lightgreen?style=for-the-badge&labelColor=darkgreen)
![Version](https://img.shields.io/badge/node_version-0.5.1_alpha5-lightgreen?style=for-the-badge&labelColor=darkgreen)

<sup>
<font color=brightred>
Expand Down
2 changes: 1 addition & 1 deletion README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="https://github.com/Gourieff/Assets/raw/main/sd-webui-reactor/ReActor_logo_NEW_RU.png?raw=true" alt="logo" width="180px"/>

![Version](https://img.shields.io/badge/версия_нода-0.5.1_alpha4-lightgreen?style=for-the-badge&labelColor=darkgreen)
![Version](https://img.shields.io/badge/версия_нода-0.5.1_alpha5-lightgreen?style=for-the-badge&labelColor=darkgreen)

<sup>
<font color=brightred>
Expand Down
16 changes: 10 additions & 6 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def __init__(self):
# self.face_helper = None
self.faces_order = ["large-small", "large-small"]
# self.face_size = FACE_SIZE
self.restore_immediately = False
self.face_boost_enabled = False
self.restore = True
self.boost_model = None
self.interpolation = "Bicubic"
Expand Down Expand Up @@ -315,12 +315,14 @@ def restore_face(
def execute(self, enabled, input_image, swap_model, detect_gender_source, detect_gender_input, source_faces_index, input_faces_index, console_log_level, face_restore_model,face_restore_visibility, codeformer_weight, facedetection, source_image=None, face_model=None, faces_order=None, face_boost=None):

if face_boost is not None:
self.restore_immediately = face_boost["enabled"]
self.face_boost_enabled = face_boost["enabled"]
self.boost_model = face_boost["boost_model"]
self.interpolation = face_boost["interpolation"]
self.boost_model_visibility = face_boost["visibility"]
self.boost_cf_weight = face_boost["codeformer_weight"]
self.restore = face_boost["restore_with_main_after"]
else:
self.face_boost_enabled = False

if faces_order is None:
faces_order = self.faces_order
Expand Down Expand Up @@ -357,7 +359,7 @@ def execute(self, enabled, input_image, swap_model, detect_gender_source, detect
face_model=face_model,
faces_order=faces_order,
# face boost:
restore_immediately=self.restore_immediately,
face_boost_enabled=self.face_boost_enabled,
face_restore_model=self.boost_model,
face_restore_visibility=self.boost_model_visibility,
codeformer_weight=self.boost_cf_weight,
Expand All @@ -371,7 +373,7 @@ def execute(self, enabled, input_image, swap_model, detect_gender_source, detect
else:
face_model_to_provide = face_model

if self.restore or not self.restore_immediately:
if self.restore or not self.face_boost_enabled:
result = reactor.restore_face(self,result,face_restore_model,face_restore_visibility,codeformer_weight,facedetection)

return (result,face_model_to_provide)
Expand Down Expand Up @@ -411,7 +413,7 @@ def __init__(self):
self.source_faces_index = "0"
self.console_log_level = 1
# self.face_size = 512
self.restore_immediately = False
self.face_boost_enabled = False
self.restore = True

def execute(self, enabled, input_image, swap_model, facedetection, face_restore_model, face_restore_visibility, codeformer_weight, source_image=None, face_model=None, options=None, face_boost=None):
Expand All @@ -425,8 +427,10 @@ def execute(self, enabled, input_image, swap_model, facedetection, face_restore_
self.source_faces_index = options["source_faces_index"]

if face_boost is not None:
self.restore_immediately = face_boost["enabled"]
self.face_boost_enabled = face_boost["enabled"]
self.restore = face_boost["restore_with_main_after"]
else:
self.face_boost_enabled = False

result = reactor.execute(
self,enabled,input_image,swap_model,self.detect_gender_source,self.detect_gender_input,self.source_faces_index,self.input_faces_index,self.console_log_level,face_restore_model,face_restore_visibility,codeformer_weight,facedetection,source_image,face_model,self.faces_order, face_boost=face_boost
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-reactor-node"
description = "The Fast and Simple Face Swap Extension Node for ComfyUI, based on ReActor SD-WebUI Face Swap Extension"
version = "0.5.1-a4"
version = "0.5.1-a5"
license = "LICENSE"
dependencies = ["insightface==0.7.3", "onnx>=1.14.0", "opencv-python>=4.7.0.72", "numpy", "segment_anything"]

Expand Down
8 changes: 4 additions & 4 deletions scripts/reactor_faceswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def process(
gender_target,
face_model,
faces_order,
restore_immediately,
face_boost_enabled,
face_restore_model,
face_restore_visibility,
codeformer_weight,
Expand All @@ -62,7 +62,7 @@ def process(
self.model = model
self.face_model = face_model
self.faces_order = faces_order
self.restore_immediately = restore_immediately
self.face_boost_enabled = face_boost_enabled
self.face_restore_model = face_restore_model
self.face_restore_visibility = face_restore_visibility
self.codeformer_weight = codeformer_weight
Expand Down Expand Up @@ -108,7 +108,7 @@ def process(
gender_target=self.gender_target,
face_model=self.face_model,
faces_order=self.faces_order,
restore_immediately=self.restore_immediately,
face_boost_enabled=self.face_boost_enabled,
face_restore_model=self.face_restore_model,
face_restore_visibility=self.face_restore_visibility,
codeformer_weight=self.codeformer_weight,
Expand Down Expand Up @@ -145,7 +145,7 @@ def process(
gender_target=self.gender_target,
face_model=self.face_model,
faces_order=self.faces_order,
restore_immediately=self.restore_immediately,
face_boost_enabled=self.face_boost_enabled,
face_restore_model=self.face_restore_model,
face_restore_visibility=self.face_restore_visibility,
codeformer_weight=self.codeformer_weight,
Expand Down
8 changes: 4 additions & 4 deletions scripts/reactor_swapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def swap_face(
gender_target: int = 0,
face_model: Union[Face, None] = None,
faces_order: List = ["large-small", "large-small"],
restore_immediately: bool = True,
face_boost_enabled: bool = False,
face_restore_model = None,
face_restore_visibility: int = 1,
codeformer_weight: float = 0.5,
Expand Down Expand Up @@ -318,7 +318,7 @@ def swap_face(
target_face, wrong_gender = get_face_single(target_img, target_faces, face_index=face_num, gender_target=gender_target, order=faces_order[0])
if target_face is not None and wrong_gender == 0:
logger.status(f"Swapping...")
if restore_immediately:
if face_boost_enabled:
logger.status(f"Face Boost is enabled")
bgr_fake, M = face_swapper.get(result, target_face, source_face, paste_back=False)
bgr_fake, scale = restorer.get_restored_face(bgr_fake, face_restore_model, face_restore_visibility, codeformer_weight, interpolation)
Expand Down Expand Up @@ -366,7 +366,7 @@ def swap_face_many(
gender_target: int = 0,
face_model: Union[Face, None] = None,
faces_order: List = ["large-small", "large-small"],
restore_immediately: bool = True,
face_boost_enabled: bool = False,
face_restore_model = None,
face_restore_visibility: int = 1,
codeformer_weight: float = 0.5,
Expand Down Expand Up @@ -511,7 +511,7 @@ def swap_face_many(
if target_face_single is not None and wrong_gender == 0:
result = target_img
logger.status(f"Swapping {i}...")
if restore_immediately:
if face_boost_enabled:
logger.status(f"Face Boost is enabled")
bgr_fake, M = face_swapper.get(target_img, target_face_single, source_face, paste_back=False)
bgr_fake, scale = restorer.get_restored_face(bgr_fake, face_restore_model, face_restore_visibility, codeformer_weight, interpolation)
Expand Down
2 changes: 1 addition & 1 deletion scripts/reactor_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
app_title = "ReActor Node for ComfyUI"
version_flag = "v0.5.1-a4"
version_flag = "v0.5.1-a5"

COLORS = {
"CYAN": "\033[0;36m", # CYAN
Expand Down

0 comments on commit 506c6cc

Please sign in to comment.