Skip to content

Commit 2749b69

Browse files
committed
added the GenderControlOutput node
1 parent b2652b7 commit 2749b69

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ This node, ColorCorrectOfUtils, is an extension of the original [ColorCorrect](h
3636
## ModifyTextGender
3737
This node adjusts the text to describe the gender based on the input. If the gender input is 'M', the text will be adjusted to describe as male; if the gender input is 'F', it will be adjusted to describe as female.
3838

39+
## GenderControlOutput
40+
This node determines the output based on the input gender. If the gender input is 'M', it will output male-specific text, float, and integer values. If the gender input is 'F', it will output female-specific text, float, and integer values.
41+
3942
## SplitMask
4043
This node splits one mask into two masks of the same size according to the area of the submasks. If there are more than two areas, it will select the two largest submasks.
4144

nodes.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,42 @@ def gender_swap(text, gender, gender_map):
314314
return ' '.join(words)
315315

316316

317+
class GenderControlOutput:
318+
"""
319+
This node will modify the prompt string according gender. gender words include M, F
320+
"""
321+
@ classmethod
322+
def INPUT_TYPES(cls):
323+
return {"required": {
324+
"gender_prior": (["", "M", "F"],),
325+
"male_text": ("STRING", {"multiline": True, "defaultBehavior": "input"}),
326+
"male_float": ("FLOAT", {"default": 1, "step": 0.1}),
327+
"male_int": ("INT", {"default": 1, "step": 1}),
328+
"female_text": ("STRING", {"multiline": True, "defaultBehavior": "input"}),
329+
"female_float": ("FLOAT", {"default": 1, "step": 0.1}),
330+
"female_int": ("INT", {"default": 1, "step": 1}),
331+
},
332+
"optional": {
333+
"gender_alternative": ("STRING", {"forceInput": True}),
334+
}
335+
}
336+
337+
RETURN_TYPES = ("STRING","FLOAT","INT","BOOLEAN","BOOLEAN")
338+
RETURN_NAMES = ("gender_text","float","int","is_male","is_female")
339+
FUNCTION = "fun"
340+
CATEGORY = "utils/text/operations"
341+
342+
@ staticmethod
343+
def fun(gender_prior,male_text,male_float,male_int,female_text,female_float,female_int, gender_alternative=None):
344+
gender= gender_prior if gender_prior else gender_alternative
345+
if gender is None or gender.upper() not in ["M", "F"]:
346+
raise Exception("can't get any gender input.")
347+
if gender.upper()== "M":
348+
return (male_text, male_float, male_int, True, False)
349+
else:
350+
return (female_text, female_float, female_int, False, True)
351+
352+
317353
class ImageConcanateOfUtils:
318354
@classmethod
319355
def INPUT_TYPES(s):
@@ -931,6 +967,7 @@ def forward(self, image, upscale_model, tile_size=512, threshold_of_xl_area=0.9)
931967
"ImageBatchOneOrMore": ImageBatchOneOrMore,
932968
"ConcatTextOfUtils": ConcatTextOfUtils,
933969
"ModifyTextGender": ModifyTextGender,
970+
"GenderControlOutput": GenderControlOutput,
934971
"IntAndIntAddOffsetLiteral": IntAndIntAddOffsetLiteral,
935972
"IntMultipleAddLiteral": IntMultipleAddLiteral,
936973
"ImageConcanateOfUtils": ImageConcanateOfUtils,
@@ -954,6 +991,7 @@ def forward(self, image, upscale_model, tile_size=512, threshold_of_xl_area=0.9)
954991
"ImageBatchOneOrMore": "Batch Images One or More",
955992
"ConcatTextOfUtils": "Concat text",
956993
"ModifyTextGender": "Modify Text Gender",
994+
"GenderControlOutput": "Gender control output",
957995
"IntAndIntAddOffsetLiteral": "Int And Int Add Offset Literal",
958996
"IntMultipleAddLiteral": "Int Multiple and Add Literal",
959997
"ImageConcanateOfUtils": "Image Concanate of utils",

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-utils-nodes"
3-
description = "Nodes:LoadImageWithSwitch, ImageBatchOneOrMore, ModifyTextGender, ImageCompositeMaskedWithSwitch, ColorCorrectOfUtils, SplitMask, MaskFastGrow, CheckpointLoaderSimpleWithSwitch, ImageResizeTo8x, MatchImageRatioToPreset, UpscaleImageWithModelIfNeed etc."
4-
version = "1.0.9"
3+
description = "Nodes:LoadImageWithSwitch, ImageBatchOneOrMore, ModifyTextGender, GenderControlOutput, ImageCompositeMaskedWithSwitch, ColorCorrectOfUtils, SplitMask, MaskFastGrow, CheckpointLoaderSimpleWithSwitch, ImageResizeTo8x, MatchImageRatioToPreset, UpscaleImageWithModelIfNeed etc."
4+
version = "1.1.0"
55
license = { file = "LICENSE" }
66
dependencies = []
77

0 commit comments

Comments
 (0)