Upload promptgen.py
Browse files- promptgen.py +148 -0
promptgen.py
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
|
3 |
+
# Feature lists and weights
|
4 |
+
weight_categories = ["lightweight", "average weight", "overweight", "obese"]
|
5 |
+
|
6 |
+
# Facial feature characteristics by weight
|
7 |
+
face_shapes = {
|
8 |
+
"lightweight": ["oval face", "angular face", "long face"],
|
9 |
+
"average weight": ["oval face", "round face", "heart-shaped face"],
|
10 |
+
"overweight": ["round face", "square face", "soft oval face"],
|
11 |
+
"obese": ["round face", "wide face", "full face"],
|
12 |
+
}
|
13 |
+
|
14 |
+
jawline_effects = {
|
15 |
+
"lightweight": ["a sharp jawline", "a defined jawline", "a slightly pointed jawline"],
|
16 |
+
"average weight": ["a balanced jawline", "a gently defined jawline", "a rounded jawline"],
|
17 |
+
"overweight": ["a soft jawline", "a subtly defined jawline", "a slightly wide jawline"],
|
18 |
+
"obese": ["a rounded jawline", "a double chin", "a soft, wide jawline"],
|
19 |
+
}
|
20 |
+
|
21 |
+
cheek_effects = {
|
22 |
+
"lightweight": ["hollow cheeks", "prominent cheekbones"],
|
23 |
+
"average weight": ["slightly prominent cheekbones", "balanced cheeks"],
|
24 |
+
"overweight": ["full cheeks", "subtle cheekbones"],
|
25 |
+
"obese": ["very full cheeks", "rounded cheeks", "no visible cheekbones"],
|
26 |
+
}
|
27 |
+
|
28 |
+
chin_effects = {
|
29 |
+
"lightweight": ["a pointed chin", "a narrow chin"],
|
30 |
+
"average weight": ["a rounded chin", "a slightly square chin"],
|
31 |
+
"overweight": ["a rounded chin", "a slightly wide chin"],
|
32 |
+
"obese": ["a very wide chin", "a soft, rounded chin"],
|
33 |
+
}
|
34 |
+
|
35 |
+
# Adjust existing features
|
36 |
+
facial_marks_by_weight = {
|
37 |
+
"lightweight": ["no visible marks", "a faint scar"],
|
38 |
+
"average weight": ["a small mole", "a faint scar", "a birthmark"],
|
39 |
+
"overweight": ["a faint scar", "a small mole"],
|
40 |
+
"obese": ["a birthmark", "no visible marks", "a small mole"],
|
41 |
+
}
|
42 |
+
|
43 |
+
wrinkles_by_weight = {
|
44 |
+
"lightweight": 0.3, # Higher likelihood due to more angular skin
|
45 |
+
"average weight": 0.2,
|
46 |
+
"overweight": 0.1,
|
47 |
+
"obese": 0.05,
|
48 |
+
}
|
49 |
+
|
50 |
+
# Additional Features
|
51 |
+
hijab_probability = {
|
52 |
+
"Middle Eastern": 0.8, # High probability
|
53 |
+
"African": 0.1,
|
54 |
+
"Asian": 0.1,
|
55 |
+
"Hispanic": 0.05,
|
56 |
+
"Caucasian": 0.0,
|
57 |
+
}
|
58 |
+
|
59 |
+
# Disabilities and Uncommon Features
|
60 |
+
disability_features = ["no left eyebrow", "no right eyebrow", "no eyelashes", "blind in one eye", "missing eye", "facial paralysis"]
|
61 |
+
tattoo_positions = ["left temple", "left cheek", "jawline", "behind the ear"]
|
62 |
+
|
63 |
+
# Feature selection system
|
64 |
+
def select_features_with_weight():
|
65 |
+
gender = random.choices(["male", "female"], weights=[50, 50], k=1)[0]
|
66 |
+
ethnicity = random.choice(["Caucasian", "African", "Asian", "Hispanic", "Middle Eastern"])
|
67 |
+
weight = random.choices(weight_categories, weights=[20, 40, 25, 15], k=1)[0]
|
68 |
+
|
69 |
+
# Hijab logic for females
|
70 |
+
wearing_hijab = gender == "female" and random.random() < hijab_probability[ethnicity]
|
71 |
+
|
72 |
+
# Basic skin tone, hair, and other ethnicity-specific features
|
73 |
+
skin_tone = random.choice(["fair", "medium", "tan", "dark", "olive"])
|
74 |
+
hair_color, hair_length, hair_style = "", "", ""
|
75 |
+
if not wearing_hijab:
|
76 |
+
hair_color = random.choice(["black", "brown", "blonde", "red", "auburn"])
|
77 |
+
hair_length = random.choices(
|
78 |
+
["short", "medium-length", "long", "shoulder-length", "buzzed"],
|
79 |
+
weights=[20, 30, 30, 15, 5] if gender == "female" else [40, 30, 15, 10, 5],
|
80 |
+
)[0]
|
81 |
+
hair_style = random.choice(["straight", "wavy", "curly", "braided", "kinky"])
|
82 |
+
|
83 |
+
# Eyes and Eyebrows
|
84 |
+
if random.random() < 0.05: # 5% chance to wear sunglasses, no eye feature
|
85 |
+
eyes = "wearing sunglasses"
|
86 |
+
eyebrows = ""
|
87 |
+
else:
|
88 |
+
eye_color = random.choice(["brown", "blue", "green", "gray", "hazel"])
|
89 |
+
eye_shape = random.choice(["almond-shaped", "round", "monolid", "upturned", "downturned"])
|
90 |
+
eyes = f"{eye_color} eyes that are {eye_shape}"
|
91 |
+
eyebrows_thickness = random.choice(["thick", "thin", "medium", "bushy", "sparse", "feathery"])
|
92 |
+
eyebrows_arch = random.choice(["arched", "straight", "rounded", "angled", "flat", "curved"])
|
93 |
+
eyebrows = f"{eyebrows_thickness} eyebrows that are {eyebrows_arch}"
|
94 |
+
|
95 |
+
# Nose, Mouth, and Disabilities
|
96 |
+
nose_shape = random.choice(["small nose", "wide nose", "medium nose"])
|
97 |
+
mouth = random.choice(["thin lips", "full lips", "bow-shaped lips", "pouty lips"])
|
98 |
+
disability = random.choice(disability_features) if random.random() < 0.1 else ""
|
99 |
+
|
100 |
+
# Facial Marks, Tattoos, Wrinkles
|
101 |
+
facial_mark = random.choice(facial_marks_by_weight[weight])
|
102 |
+
tattoo = random.choice(tattoo_positions) if random.random() < 0.05 else ""
|
103 |
+
wrinkles = random.random() < wrinkles_by_weight[weight]
|
104 |
+
|
105 |
+
# Wrinkle logic based on age, ethnicity, and weight
|
106 |
+
if wrinkles:
|
107 |
+
wrinkles = True
|
108 |
+
else:
|
109 |
+
wrinkles = False
|
110 |
+
|
111 |
+
# Weight-based features: face shape, jawline, chin, cheeks
|
112 |
+
face_shape = random.choice(face_shapes[weight])
|
113 |
+
jawline = random.choice(jawline_effects[weight])
|
114 |
+
cheeks = random.choice(cheek_effects[weight])
|
115 |
+
chin = random.choice(chin_effects[weight])
|
116 |
+
|
117 |
+
# Build prompt
|
118 |
+
prompt = f"A {random.randint(18, 75)}-year-old {gender} of {ethnicity} ethnicity with {skin_tone} skin. "
|
119 |
+
|
120 |
+
if wearing_hijab:
|
121 |
+
prompt += f"Wearing a hijab. "
|
122 |
+
else:
|
123 |
+
prompt += f"{hair_length} {hair_color} {hair_style} hair. "
|
124 |
+
|
125 |
+
prompt += f"{eyes}, {eyebrows}, a {nose_shape} nose, {mouth}. "
|
126 |
+
prompt += f"{face_shape}, {jawline}, {cheeks}, {chin}. "
|
127 |
+
|
128 |
+
if disability:
|
129 |
+
prompt += f"Has a disability: {disability}. "
|
130 |
+
if facial_mark:
|
131 |
+
prompt += f"They have {facial_mark}. "
|
132 |
+
if tattoo:
|
133 |
+
prompt += f"Has a tattoo on {tattoo}. "
|
134 |
+
if wrinkles:
|
135 |
+
prompt += "They have visible wrinkles. "
|
136 |
+
|
137 |
+
return prompt.strip()
|
138 |
+
|
139 |
+
# Generate detailed prompts
|
140 |
+
detailed_prompts = [select_features_with_weight() for _ in range(50000)]
|
141 |
+
|
142 |
+
# Save to a file
|
143 |
+
file_path = "improved_facial_description_prompts.txt"
|
144 |
+
with open(file_path, "w") as f:
|
145 |
+
for prompt in detailed_prompts:
|
146 |
+
f.write(prompt + "\n")
|
147 |
+
|
148 |
+
print(f"Prompts saved to {file_path}")
|