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elements dataset - Improved with a focus on natural light and textures
|
| 6 |
+
FASHION_ELEMENTS = {
|
| 7 |
+
"colors": [
|
| 8 |
+
"intense ruby", "classic black", "emerald green", "sapphire blue", "royal purple",
|
| 9 |
+
"champagne gold", "metallic silver", "burgundy wine", "chocolate brown", "ivory white",
|
| 10 |
+
"intense pink", "electric blue", "vibrant orange", "forest green", "midnight navy",
|
| 11 |
+
"soft lavender", "peach coral", "platinum silver", "rose gold", "caramel nude"
|
| 12 |
+
],
|
| 13 |
+
"outfits": [
|
| 14 |
+
"fitted mini dress with subtle texture that caresses curves",
|
| 15 |
+
"A-line mini skirt with a delicate blouse that flows with movement",
|
| 16 |
+
"tight bodycon dress with elegant draping that follows the silhouette",
|
| 17 |
+
"sheath mini dress with unique details that catch the light",
|
| 18 |
+
"playful skater dress with a flattering silhouette that moves harmoniously",
|
| 19 |
+
"mini wrap dress that elegantly accentuates the waist",
|
| 20 |
+
"modern slip dress with a luxurious satin finish that shines softly",
|
| 21 |
+
"pencil mini skirt with a modern cut that emphasizes the figure",
|
| 22 |
+
"flowing chiffon dress with intricate patterns that create a play of light",
|
| 23 |
+
"fitted leather mini skirt with bold accents that contrast with softness"
|
| 24 |
+
],
|
| 25 |
+
"lingerie_thongs": [
|
| 26 |
+
"Belgian floral lace thongs with delicate patterns",
|
| 27 |
+
"thongs with French bow details and chantilly lace",
|
| 28 |
+
"sheer thongs with geometric lace and shimmering threads",
|
| 29 |
+
"thongs with high-quality guipure lace scalloped edges",
|
| 30 |
+
"plain thongs with stretchy lace that adapts perfectly",
|
| 31 |
+
"textured thongs with relief lace and 3D motifs",
|
| 32 |
+
"shimmering thongs with metallic lace that reflects light",
|
| 33 |
+
"light leavers lace thongs with strategic transparencies",
|
| 34 |
+
"thongs with an openwork lace net pattern that creates a play of shadows",
|
| 35 |
+
"embroidered thongs with silk threads and pearl details",
|
| 36 |
+
"thongs with delicate chantilly lace straps and appliqués",
|
| 37 |
+
"soft plush thongs with luxurious lace inserts",
|
| 38 |
+
"thongs with a sophisticated Venetian lace leaf motif",
|
| 39 |
+
"thongs with high-definition stretch lace transparent panels",
|
| 40 |
+
"shimmering thongs with satin lace that catches every ray of light",
|
| 41 |
+
"thongs with flowing French elastic lace edges",
|
| 42 |
+
"thongs with bold lines contrasted with soft lace",
|
| 43 |
+
"romantic Alençon lace thongs with traditional patterns",
|
| 44 |
+
"soft fur thongs with delicate lace appliqués",
|
| 45 |
+
"thongs with elegant luxurious corded lace draping"
|
| 46 |
+
],
|
| 47 |
+
"lingerie_bras": [
|
| 48 |
+
"push-up bra with delicate lace",
|
| 49 |
+
"underwire bra with precise contour lace",
|
| 50 |
+
"sheer cup bra with openwork lace",
|
| 51 |
+
"demi-cup bra with high-quality stretch lace",
|
| 52 |
+
"plain cup bra with subtle lace details",
|
| 53 |
+
"padded bra with soft-touch lace",
|
| 54 |
+
"balconette bra with French chantilly lace",
|
| 55 |
+
"light coverage bra with stretch lace",
|
| 56 |
+
"bra with sheer straps and applied lace",
|
| 57 |
+
"embroidered bra with luxury guipure lace"
|
| 58 |
+
],
|
| 59 |
+
"lingerie_details": [
|
| 60 |
+
"delicate lace details with scalloped edges",
|
| 61 |
+
"satin accessories that complement the lace",
|
| 62 |
+
"strategic sheer panels that showcase the lace",
|
| 63 |
+
"scalloped edges that emphasize the lace texture",
|
| 64 |
+
"embellished with subtle crystals on the lace pattern",
|
| 65 |
+
"bow details that enhance the delicacy of the lace",
|
| 66 |
+
"plunging neckline that shows the bra's lace",
|
| 67 |
+
"underwire support discreetly integrated into the lace",
|
| 68 |
+
"removable garters that harmonize with the lace set"
|
| 69 |
+
],
|
| 70 |
+
"stockings": [
|
| 71 |
+
"sheer high stockings with a lace top that matches the thong",
|
| 72 |
+
"fishnet high stockings with a pattern that complements the lace design",
|
| 73 |
+
"silk high stockings with a soft finish that contrasts with the lace texture",
|
| 74 |
+
"high stockings with garters that integrate with the lace set",
|
| 75 |
+
"velvet high stockings with a soft texture next to the lace",
|
| 76 |
+
"satin high stockings with a subtle sheen that harmonizes with the lace",
|
| 77 |
+
"mesh high stockings with a net pattern that complements the lace",
|
| 78 |
+
"high stockings with a light, airy feel that doesn't compete with the lace",
|
| 79 |
+
"opaque high stockings with a matte look that contrasts with the lace's shine",
|
| 80 |
+
"sheer high stockings with a tint that coordinates with the lace color"
|
| 81 |
+
],
|
| 82 |
+
"hairstyles": [
|
| 83 |
+
"long reddish-brown hair with elegant waves that catch natural light",
|
| 84 |
+
"long and straight platinum blonde hair that flows with golden highlights under the sun",
|
| 85 |
+
"long dark brown hair with soft curls that create a play of light and shadows",
|
| 86 |
+
"long layered red hair with a voluminous style that glows in the daylight",
|
| 87 |
+
"long and straight black hair with a glossy finish that reflects ambient light",
|
| 88 |
+
"long golden blonde hair with beach waves that shimmer in natural light",
|
| 89 |
+
"long brown hair with braids and loose ends that softly catch the light",
|
| 90 |
+
"intricate updo with honey highlights that shine under the daylight",
|
| 91 |
+
"long messy mahogany hair with dimensions enhanced by natural light",
|
| 92 |
+
"long and straight cherry red hair that glows intensely under daylight"
|
| 93 |
+
],
|
| 94 |
+
"expressions": [
|
| 95 |
+
"seductive gaze full of desire, with eyes slightly squinted by natural light",
|
| 96 |
+
"soft and confident gaze, with the face bathed in warm daylight",
|
| 97 |
+
"intimate yet professional gaze, with natural expressions enhanced by soft light",
|
| 98 |
+
"focused gaze, with bright eyes thanks to natural lighting",
|
| 99 |
+
"confident or slightly flirtatious gaze, accented by natural reflections",
|
| 100 |
+
"direct and secure gaze, with makeup perfectly lit by daylight",
|
| 101 |
+
"mysterious gaze, with natural shadows that add depth to the expression",
|
| 102 |
+
"suggestive and soft gaze, enhanced by the ambient glow",
|
| 103 |
+
"seductive gaze at the camera, with natural glints in the eyes",
|
| 104 |
+
"intense and passionate gaze, with natural light accentuating every emotional nuance"
|
| 105 |
+
],
|
| 106 |
+
"boudoir_office_poses": [
|
| 107 |
+
"semi-open legs with a slight torso twist, hands softly touching the skirt or the lace thong, direct and confident gaze",
|
| 108 |
+
"sitting on the edge of the desk with one leg crossed over the other, skirt delicately lifted with one hand to reveal the lace",
|
| 109 |
+
"gently leaning over the desk with semi-open legs, one hand on the table and the other subtly lifting the skirt to show the lace texture",
|
| 110 |
+
"walking with the skirt slightly lifted, one leg forward in a natural step, hands adjusting accessories while natural light caresses the lace",
|
| 111 |
+
"standing next to the desk with semi-open legs, one hand on the table while the other subtly touches the skirt near the visible lace",
|
| 112 |
+
"standing with one leg forward and skirt subtly moved, weight on the back leg with the skirt sliding to show the delicate lace",
|
| 113 |
+
"leaning on a chair turned backward, semi-open legs, skirt gently lifted with hands on the waist to emphasize the lace texture",
|
| 114 |
+
"crossed legs with the skirt shifted, ensuring a natural and feminine posture that shows glimpses of the lace with elegance",
|
| 115 |
+
"one leg slightly elevated and resting against a surface, hand touching the skirt or the lace thong to highlight its texture",
|
| 116 |
+
"hands on the waist subtly lifting the garment to show the lace thong, erect posture and confident gaze with natural light caressing the textures"
|
| 117 |
+
],
|
| 118 |
+
"camera_angles": [
|
| 119 |
+
"extremely low angle from ground level, slightly tilted up, filling the frame up close to capture every detail of the lace",
|
| 120 |
+
"worm's-eye view, gently tilted up, focusing tightly on the textures and details",
|
| 121 |
+
"low angle capturing the full figure from below, gently tilted up, filling the frame to highlight the lace textures",
|
| 122 |
+
"dramatic low angle emphasizing height and shape, gently tilted up, filling the frame to show intricate details",
|
| 123 |
+
"close-up from a low angle focusing on the lower body and outfit from below, gently tilted up, filling the frame with detailed textures"
|
| 124 |
+
],
|
| 125 |
+
"backgrounds": [
|
| 126 |
+
"modern executive office with large windows that flood the space with natural daylight and city views",
|
| 127 |
+
"chic minimalist office with soft natural light entering through large windows, creating soft reflections on smooth surfaces",
|
| 128 |
+
"luxurious hotel suite with upholstered furniture and large windows that allow abundant daylight to pass through",
|
| 129 |
+
"sophisticated office with elegant decor and floor-to-ceiling windows that bathe the scene in natural light",
|
| 130 |
+
"modern art gallery with clean lines and skylights that distribute natural light evenly",
|
| 131 |
+
"executive library with wooden bookshelves and arched windows that project patterns of natural light",
|
| 132 |
+
"industrial loft with large antique windows that filter daylight atmospherically",
|
| 133 |
+
"premium boardroom with a polished wooden table that reflects the natural light from large windows",
|
| 134 |
+
"executive penthouse with an indoor terrace and glass walls that maximize natural light entry",
|
| 135 |
+
"photo studio with natural light simulated by large diffusing windows"
|
| 136 |
+
],
|
| 137 |
+
"lighting": [
|
| 138 |
+
"soft diffuse natural light entering through large windows, creating delicate reflections on lace textures",
|
| 139 |
+
"daylight filtered through translucent curtains, softening shadows and accentuating details",
|
| 140 |
+
"direct natural light from mid-afternoon that creates interesting patterns and highlights the intricate lace texture",
|
| 141 |
+
"golden hour light that bathes the scene in warm tones and enhances textile details",
|
| 142 |
+
"daytime ambient light that gently envelops the subject, minimizing harsh shadows and highlighting qualities",
|
| 143 |
+
"bright high-key natural light that illuminates uniformly without overexposing delicate details",
|
| 144 |
+
"dramatic low-key daylight that creates soft contrasts and emphasizes the dimensions of the lace",
|
| 145 |
+
"natural contour light that softly highlights the silhouette and enhances textured edges",
|
| 146 |
+
"soft north-facing window light that provides consistent and flattering illumination for detailed textures",
|
| 147 |
+
"reflected natural light that bounces off light surfaces, creating a soft, enveloping illumination"
|
| 148 |
+
],
|
| 149 |
+
"texture_emphasis": [
|
| 150 |
+
"extreme emphasis on the intricate texture of the lace, capturing every thread and pattern with crystal clarity",
|
| 151 |
+
"sharp focus on the tactile quality of the lace, showing its delicacy and dimensional structure",
|
| 152 |
+
"highlighting the interaction between natural light and the textured surfaces of the lace",
|
| 153 |
+
"enhancing the depth and complexity of the lace patterns with precise natural lighting",
|
| 154 |
+
"capturing the tactile sensuality of the lace against the skin, with every detail visible and tangible",
|
| 155 |
+
"showcasing the play of transparencies and opacities in the lace design with natural light",
|
| 156 |
+
"emphasis on the luxurious quality of the lace and its natural drape on the figure",
|
| 157 |
+
"highlighting the contrasts between the dense and transparent areas of the lace pattern",
|
| 158 |
+
"capturing the softness and flexibility of the elastic lace as it conforms to curves",
|
| 159 |
+
"showcasing the subtle reflections and light-absorbing qualities of different types of lace"
|
| 160 |
+
]
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
# Photography specifications - Improved for natural light and textures
|
| 164 |
+
PHOTOGRAPHY_SPECS = {
|
| 165 |
+
"description": (
|
| 166 |
+
"(masterpiece, top quality:1.4), Ultra HD 16K (15360×8640), "
|
| 167 |
+
"professional boudoir photography in an office with natural light, Canon EOS R5 Cine RAW + Canon RF 85mm f/1.2L USM, "
|
| 168 |
+
"soft diffuse natural light entering through large windows, perfectly enhancing the lace texture without harsh shadows, "
|
| 169 |
+
"cinematic color grading in natural warm tones, 9:16 vertical format, "
|
| 170 |
+
"sharp and delicate details of lace and skin textures. (watermark BATUTO-ART:0.4)"
|
| 171 |
+
),
|
| 172 |
+
"negative_prompt": (
|
| 173 |
+
"nsfw, nude, explicit content, deformed, bad anatomy, additional limbs, "
|
| 174 |
+
"blurry, low quality, cartoon, anime, minor, grotesque, "
|
| 175 |
+
"poor lighting, harsh shadows, vulgar, stiff pose, distortion, hands covering the lingerie, "
|
| 176 |
+
"bad framing, subject too small, empty space, poor cropping, cut limbs, out of frame, "
|
| 177 |
+
"border, frame, outline, uneven lighting, dark areas, noisy, oversaturated, "
|
| 178 |
+
"underexposed, overexposed, text, watermark, signature, grain, 3d, painting, illustration, "
|
| 179 |
+
"monochrome, black and white, sepia, vintage, plastic, doll, retouched, photoshopped, fake, surreal"
|
| 180 |
+
)
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
class FashionPromptGenerator:
|
| 184 |
+
def __init__(self):
|
| 185 |
+
self.fashion_elements = FASHION_ELEMENTS
|
| 186 |
+
self.photo_specs = PHOTOGRAPHY_SPECS
|
| 187 |
+
|
| 188 |
+
def generate_prompt(self, celebrity_name: str) -> str:
|
| 189 |
+
"""Generate a single fashion photography prompt with a focus on natural light and lace texture"""
|
| 190 |
+
primary_color = random.choice(self.fashion_elements["colors"])
|
| 191 |
+
outfit = random.choice(self.fashion_elements["outfits"])
|
| 192 |
+
thong = random.choice(self.fashion_elements["lingerie_thongs"])
|
| 193 |
+
bra = random.choice(self.fashion_elements["lingerie_bras"]) if random.random() > 0.5 else None
|
| 194 |
+
lingerie_item = f"{primary_color} {thong}"
|
| 195 |
+
|
| 196 |
+
if bra:
|
| 197 |
+
lingerie_item += f" and {primary_color} {bra}"
|
| 198 |
+
|
| 199 |
+
lingerie_detail = random.choice(self.fashion_elements["lingerie_details"])
|
| 200 |
+
stocking = f"{primary_color} {random.choice(self.fashion_elements['stockings'])}"
|
| 201 |
+
pose = random.choice(self.fashion_elements["boudoir_office_poses"])
|
| 202 |
+
hairstyle = random.choice(self.fashion_elements["hairstyles"])
|
| 203 |
+
background = random.choice(self.fashion_elements["backgrounds"])
|
| 204 |
+
lighting = random.choice(self.fashion_elements["lighting"])
|
| 205 |
+
camera_angle = random.choice(self.fashion_elements["camera_angles"])
|
| 206 |
+
expression = random.choice(self.fashion_elements["expressions"])
|
| 207 |
+
texture_emphasis = random.choice(self.fashion_elements["texture_emphasis"])
|
| 208 |
+
|
| 209 |
+
prompt = f"""A sensual photograph of the beautiful celebrity {celebrity_name}, captured from a {camera_angle} to emphasize the texture of the skirt, the visible {primary_color} {thong}, and then ascending towards the face with flawless makeup. The camera is positioned slightly below the garment's level, near the floor or knees, to highlight details and add drama and depth, emphasizing textures and shapes. The framing is tight and close, completely filling the frame.
|
| 210 |
+
|
| 211 |
+
The composition frames from the lower body to the face or makeup, using the pose and gaze to guide the viewer's attention.
|
| 212 |
+
|
| 213 |
+
{celebrity_name} wears a meticulously designed {primary_color} {outfit}, with {lingerie_item} and {lingerie_detail}. She is also wearing {stocking}. {pose}, with {hairstyle}. Expression: {expression}. Set in {background} with {lighting}.
|
| 214 |
+
|
| 215 |
+
{texture_emphasis}
|
| 216 |
+
|
| 217 |
+
**Capture Technique:**
|
| 218 |
+
- **Angle and Framing:** {camera_angle}
|
| 219 |
+
- **Distance:** Close-up, capturing fine details in the fabric, lace, or finishes without losing context
|
| 220 |
+
- **Lighting:** {lighting}, using soft and directional natural light or diffusers
|
| 221 |
+
- **Pose:** Poses with slight tilts or twists, gently crossed legs, hands gently touching the skirt or lingerie
|
| 222 |
+
|
| 223 |
+
{self.photo_specs['description']}
|
| 224 |
+
|
| 225 |
+
**Negative prompt:** {self.photo_specs['negative_prompt']}
|
| 226 |
+
"""
|
| 227 |
+
return prompt.strip()
|
| 228 |
+
|
| 229 |
+
def generate_five_prompts(self, celebrity_name: str) -> List[str]:
|
| 230 |
+
"""Generate five unique fashion photography prompts"""
|
| 231 |
+
return [self.generate_prompt(celebrity_name) for _ in range(5)]
|
| 232 |
+
|
| 233 |
+
def create_gradio_interface():
|
| 234 |
+
"""Create and configure the Gradio interface"""
|
| 235 |
+
generator = FashionPromptGenerator()
|
| 236 |
+
|
| 237 |
+
with gr.Blocks(
|
| 238 |
+
title="Fashion Prompt Generator - Office Boudoir Style",
|
| 239 |
+
theme=gr.themes.Soft(),
|
| 240 |
+
css="""
|
| 241 |
+
.prompt-box {
|
| 242 |
+
border: 1px solid #e2e8f0;
|
| 243 |
+
border-radius: 8px;
|
| 244 |
+
padding: 16px;
|
| 245 |
+
margin-bottom: 16px;
|
| 246 |
+
background-color: #f8fafc;
|
| 247 |
+
}
|
| 248 |
+
.prompt-title {
|
| 249 |
+
font-weight: bold;
|
| 250 |
+
margin-bottom: 8px;
|
| 251 |
+
color: #4a5568;
|
| 252 |
+
}
|
| 253 |
+
.dark .prompt-box {
|
| 254 |
+
background-color: #2d3748;
|
| 255 |
+
border-color: #4a5568;
|
| 256 |
+
}
|
| 257 |
+
.dark .prompt-title {
|
| 258 |
+
color: #e2e8f0;
|
| 259 |
+
}
|
| 260 |
+
"""
|
| 261 |
+
) as demo:
|
| 262 |
+
gr.Markdown("# ✨ Fashion Prompt Generator - Office Boudoir Style ✨")
|
| 263 |
+
gr.Markdown("Enter a celebrity's name to generate 5 unique and detailed fashion photography prompts with a focus on natural light and lace textures.")
|
| 264 |
+
|
| 265 |
+
with gr.Row():
|
| 266 |
+
with gr.Column(scale=3):
|
| 267 |
+
celebrity_input = gr.Textbox(
|
| 268 |
+
label="Celebrity Name",
|
| 269 |
+
placeholder="E.g.: Scarlett Johansson, Zendaya, Ana de Armas...",
|
| 270 |
+
info="The name of the celebrity that will appear in the prompts."
|
| 271 |
+
)
|
| 272 |
+
with gr.Column(scale=1):
|
| 273 |
+
generate_btn = gr.Button("Generate 5 Prompts", variant="primary", size="lg")
|
| 274 |
+
clear_btn = gr.Button("Clear All", variant="secondary")
|
| 275 |
+
|
| 276 |
+
gr.Markdown("## Generated Prompts")
|
| 277 |
+
|
| 278 |
+
output_prompts = []
|
| 279 |
+
prompt_columns = []
|
| 280 |
+
|
| 281 |
+
for i in range(5):
|
| 282 |
+
with gr.Column(visible=False) as prompt_col:
|
| 283 |
+
gr.Markdown(f"### Prompt {i+1}", elem_classes="prompt-title")
|
| 284 |
+
prompt_output = gr.Textbox(
|
| 285 |
+
label="",
|
| 286 |
+
lines=15,
|
| 287 |
+
max_lines=20,
|
| 288 |
+
interactive=False,
|
| 289 |
+
elem_id=f"prompt_output_{i}",
|
| 290 |
+
show_copy_button=True,
|
| 291 |
+
elem_classes="prompt-box"
|
| 292 |
+
)
|
| 293 |
+
output_prompts.append(prompt_output)
|
| 294 |
+
prompt_columns.append(prompt_col)
|
| 295 |
+
|
| 296 |
+
def generate_and_display_prompts(celebrity_name):
|
| 297 |
+
"""Generate prompts and make columns visible"""
|
| 298 |
+
if not celebrity_name.strip():
|
| 299 |
+
return [gr.update(visible=False)] * 5 + [""] * 5
|
| 300 |
+
prompts = generator.generate_five_prompts(celebrity_name)
|
| 301 |
+
return [gr.update(visible=True)] * 5 + prompts
|
| 302 |
+
|
| 303 |
+
def clear_all():
|
| 304 |
+
"""Clear all outputs and hide columns"""
|
| 305 |
+
return [gr.update(visible=False)] * 5 + [""] * 5
|
| 306 |
+
|
| 307 |
+
# Event handlers
|
| 308 |
+
generate_btn.click(
|
| 309 |
+
fn=generate_and_display_prompts,
|
| 310 |
+
outputs=prompt_columns + output_prompts,
|
| 311 |
+
inputs=celebrity_input,
|
| 312 |
+
queue=False
|
| 313 |
+
)
|
| 314 |
+
clear_btn.click(
|
| 315 |
+
fn=clear_all,
|
| 316 |
+
outputs=prompt_columns + output_prompts,
|
| 317 |
+
queue=False
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
if __name__ == '__main__':
|
| 321 |
+
create_gradio_interface().launch()
|
| 322 |
+
|