forked from florestefano1975/comfyui-portrait-master
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PortraitMasterStylePose.py
154 lines (130 loc) · 4.92 KB
/
PortraitMasterStylePose.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import random
from .common import *
# Portrait Master Style & Pose
class PortraitMasterStylePose:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
max_float_value = 2
return {
"optional": {
"text_in": ("STRING", {"forceInput": True}),
"seed": ("INT", {"forceInput": True}),
},
"required": {
"模特姿势": (['-'] + [rand_opt] + lists['model_pose'], {
"default": '-',
}),
"服装": (['-'] + [rand_opt] + lists['clothes'], {
"default": '-',
}),
"女士内衣": (['-'] + [rand_opt] + lists['female_lingerie'], {
"default": '-',
}),
"妆容": (['-'] + [rand_opt] + lists['makeup'], {
"default": '-',
}),
"光照类型": (['-'] + [rand_opt] + lists['light_type'], {
"default": '-',
}),
"光照方向": (['-'] + [rand_opt] + lists['light_direction'], {
"default": '-',
}),
"光照权重": ("FLOAT", {
"default": 1,
"min": 0,
"max": max_float_value,
"step": 0.05,
"display": "slider",
}),
"style_1": (['-'] + [rand_opt] + lists['style'], {
"default": '-',
}),
"style_1_weight": ("FLOAT", {
"default": 1,
"min": 0,
"max": max_float_value,
"step": 0.05,
"display": "slider",
}),
"style_2": (['-'] + [rand_opt] + lists['style'], {
"default": '-',
}),
"style_2_weight": ("FLOAT", {
"default": 1,
"min": 0,
"max": max_float_value,
"step": 0.05,
"display": "slider",
}),
"照片写实增强": ("BOOLEAN", {"default": True}),
"启用": ("BOOLEAN", {"default": True}),
}
}
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("text_out",)
FUNCTION = "pmsp"
CATEGORY = CATEGORY
def pmsp(
self,
text_in='',
seed=0,
模特姿势='-',
服装='-',
女士内衣='-',
妆容='-',
光照类型='-',
光照方向='-',
光照权重=1,
style_1='-',
style_1_weight=1,
style_2='-',
style_2_weight=1,
照片写实增强=False,
启用=True
):
prompt = []
if text_in != '':
prompt.append(text_in)
if 启用:
if 妆容 == rand_opt:
妆容 = random.choice(lists['makeup'])
if 妆容 != '-':
prompt.append(f"({dicts['makeup'][妆容]}:1.05)")
if 模特姿势 == rand_opt:
模特姿势 = random.choice(lists['model_pose'])
if 模特姿势 != '-':
prompt.append(f"({dicts['model_pose'][模特姿势]}:1.25)")
if 服装 == rand_opt:
服装 = random.choice(lists['clothes'])
if 服装 != '-':
prompt.append(f"({dicts['clothes'][服装]}:1.25)")
if 女士内衣 == rand_opt:
女士内衣 = random.choice(lists['female_lingerie'])
if 女士内衣 != '-':
prompt.append(f"({dicts['female_lingerie'][女士内衣]}:1.25)")
if 光照类型 == rand_opt:
光照类型 =random.choice(lists['light_type'])
if 光照类型 != '-':
prompt.append(applyWeight(dicts['light_type'][光照类型],光照权重))
if 光照方向 == rand_opt:
光照方向 = random.choice(lists['light_direction'])
if 光照方向 != '-':
prompt.append(applyWeight(dicts['light_direction'][光照方向],光照权重))
if style_1 == rand_opt:
style_1 = random.choice(lists['style'])
if style_1 != '-':
prompt.append(applyWeight(dicts['style'][style_1],style_1_weight))
if style_2 == rand_opt:
style_2 = random.choice(lists['style'])
if style_2 != '-':
prompt.append(applyWeight(dicts['style'][style_2],style_2_weight))
if 照片写实增强:
prompt.append('(professional photo, balanced photo, balanced exposure:1.2)')
if len(prompt) > 0:
prompt = ', '.join(prompt)
prompt = prompt.lower()
return(prompt,)
else:
return('',)