Actualizar app.py
Browse files
app.py
CHANGED
|
@@ -1,96 +1,137 @@
|
|
| 1 |
-
import os
|
| 2 |
import random
|
| 3 |
import gradio as gr
|
| 4 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 7 |
-
|
| 8 |
-
# Inicializa el modelo Mistral con token Hugging Face
|
| 9 |
-
model = InferenceClientModel(
|
| 10 |
-
model_id="mistralai/Mistral-7B-Instruct-v0.1",
|
| 11 |
-
token=HF_TOKEN,
|
| 12 |
-
)
|
| 13 |
-
|
| 14 |
-
# Datos básicos para generar prompts
|
| 15 |
-
ROLES = [
|
| 16 |
-
"nurse", "nun", "doctor", "secretary", "teacher", "schoolgirl", "lawyer"
|
| 17 |
-
]
|
| 18 |
-
|
| 19 |
-
HAIR_STYLES = [
|
| 20 |
-
"long flowing chestnut hair styled in soft waves",
|
| 21 |
-
"sleek straight long black hair",
|
| 22 |
-
"luxurious long blonde curls",
|
| 23 |
-
]
|
| 24 |
-
|
| 25 |
-
EYE_COLORS = [
|
| 26 |
-
"intense brown", "bright sapphire blue", "emerald green"
|
| 27 |
-
]
|
| 28 |
-
|
| 29 |
-
OUTFIT_TEMPLATES = {
|
| 30 |
-
"nurse": "a classic short nurse dress, thigh-high stockings, semi-transparent lace panties, no bra, elegant high heels",
|
| 31 |
-
"nun": "a sensual interpretation of a nun's habit with a revealing long robe and thigh-high stockings",
|
| 32 |
-
"doctor": "a daring white lab coat minidress left slightly open, thigh-high stockings",
|
| 33 |
-
"secretary": "a provocative office pencil skirt and sheer blouse, thigh-high stockings",
|
| 34 |
-
"teacher": "a fitted blazer over a silk blouse and short skirt, thigh-high stockings",
|
| 35 |
-
"schoolgirl": "a short pleated skirt and white blouse, thigh-high stockings",
|
| 36 |
-
"lawyer": "a tailored suit with skirt cut above knees, silk blouse unbuttoned slightly, thigh-high stockings"
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
-
POSES = [
|
| 40 |
-
"standing gracefully with one leg slightly forward",
|
| 41 |
-
"seated on the edge, legs crossed",
|
| 42 |
-
"bending forward slightly as if picking something up"
|
| 43 |
-
]
|
| 44 |
-
|
| 45 |
-
SETTINGS = [
|
| 46 |
-
"a modern professional office with golden sunset light and sophisticated decor",
|
| 47 |
-
"a stylish hospital room with clean bright tones and realistic medical equipment",
|
| 48 |
-
"a luxurious bedroom with silk sheets and soft lighting"
|
| 49 |
-
]
|
| 50 |
-
|
| 51 |
-
ATMOSPHERES = [
|
| 52 |
-
"soft professional lighting with perfect color, crisp highlights and smooth skin shadows",
|
| 53 |
-
"warm ambient sunlight, rich gold reflections and depth",
|
| 54 |
-
"moody cinematic lighting with dramatic shadows and highlights"
|
| 55 |
-
]
|
| 56 |
-
|
| 57 |
-
TECHNICAL_DETAILS = (
|
| 58 |
-
"shot in full vertical 9:16 aspect ratio capturing the entire figure with natural human proportions and anatomical precision, "
|
| 59 |
-
"featuring hyperrealistic skin texture with subtle imperfections, perfect makeup and natural fabric and hair strand details. "
|
| 60 |
-
"Captured with professional camera gear (Canon R5, 85mm lens, f/1.2) emphasizing soft, natural lighting and highlights for humanized photorealism. "
|
| 61 |
-
"Exclude any cartoon, 2D, painting, stylized, CGI, low resolution or watermark artifacts."
|
| 62 |
-
)
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
def generate_prompt():
|
| 66 |
-
role = random.choice(ROLES)
|
| 67 |
-
hair_style = random.choice(HAIR_STYLES)
|
| 68 |
-
eye_color = random.choice(EYE_COLORS)
|
| 69 |
-
outfit = OUTFIT_TEMPLATES[role]
|
| 70 |
-
pose = random.choice(POSES)
|
| 71 |
-
setting = random.choice(SETTINGS)
|
| 72 |
-
atmosphere = random.choice(ATMOSPHERES)
|
| 73 |
-
|
| 74 |
-
prompt_text = (
|
| 75 |
-
f"A hyperrealistic full-body portrait of a sensual {role} with {hair_style} and {eye_color} eyes, "
|
| 76 |
-
f"perfect makeup and flawless skin with subtle natural imperfections. Wearing {outfit}. "
|
| 77 |
-
f"Pose: {pose}. Scene: {setting} with {atmosphere}. "
|
| 78 |
-
f"{TECHNICAL_DETAILS}"
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
return f"``````"
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
def generate_five_prompts():
|
| 85 |
-
return [generate_prompt() for _ in range(5)]
|
| 86 |
|
|
|
|
| 87 |
|
| 88 |
with gr.Blocks() as demo:
|
| 89 |
-
gr.Markdown("
|
| 90 |
output = gr.Textbox(label="Generated Prompts", lines=20)
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
btn.click(fn=lambda: "\n\n".join(generate_five_prompts()), outputs=output)
|
| 94 |
|
| 95 |
if __name__ == "__main__":
|
| 96 |
demo.launch()
|
|
|
|
|
|
|
| 1 |
import random
|
| 2 |
import gradio as gr
|
| 3 |
+
from typing import Optional, Dict, Any
|
| 4 |
+
|
| 5 |
+
class PromptGenerator:
|
| 6 |
+
def __init__(self):
|
| 7 |
+
self.ROLES = [
|
| 8 |
+
"nurse", "nun", "doctor", "secretary", "teacher", "schoolgirl", "lawyer",
|
| 9 |
+
"yoga instructor", "policewoman", "female military officer in gala uniform",
|
| 10 |
+
"WWII-era secretary", "1960s flight attendant", "boudoir model",
|
| 11 |
+
"elegant judge", "seductive librarian", "sensual model", "alluring secretary",
|
| 12 |
+
"elegant flight attendant", "seductive maid", "mysterious nurse",
|
| 13 |
+
"captivating schoolgirl", "business executive", "fitness model"
|
| 14 |
+
]
|
| 15 |
+
self.HAIR_COLORS = [
|
| 16 |
+
"deep sapphire blue", "silver platinum", "vibrant ruby red", "glossy jet black",
|
| 17 |
+
"luxurious chestnut brown", "emerald green", "vivid amethyst purple",
|
| 18 |
+
"chocolate brown", "honey blonde", "burgundy red"
|
| 19 |
+
]
|
| 20 |
+
self.EYE_COLORS = [
|
| 21 |
+
"intense brown", "bright sapphire blue", "emerald green", "golden amber",
|
| 22 |
+
"fascinating hazel", "deep violet", "piercing emerald", "deep sapphire",
|
| 23 |
+
"intense amber", "hypnotic hazel", "vibrant violet", "mysterious gray"
|
| 24 |
+
]
|
| 25 |
+
self.HAIR_STYLES = [
|
| 26 |
+
"long flowing chestnut hair styled in soft waves", "sleek straight long black hair",
|
| 27 |
+
"luxurious long blonde curls", "elegant updo with loose cascading strands",
|
| 28 |
+
"glossy long brunette hair parted in the middle", "long flowing waves",
|
| 29 |
+
"luxurious straight hair", "voluminous curls", "elegant updo with cascading strands",
|
| 30 |
+
"thick braid over the shoulder", "loose and silky layers", "messy chic bun"
|
| 31 |
+
]
|
| 32 |
+
self.OUTFIT_TEMPLATES = {
|
| 33 |
+
"nurse": "a classic short nurse dress, thigh-high stockings, semi-transparent lace panties subtly slipping down as if accidentally revealed beneath a skirt, no bra, elegant high heels",
|
| 34 |
+
"nun": "a sensual interpretation of a nun's habit with a revealing long robe and thigh-high stockings, semi-transparent lace panties suggesting a playful accidental reveal, no bra, black stiletto heels",
|
| 35 |
+
"doctor": "a daring white lab coat minidress left slightly open, thigh-high stockings, semi-transparent lace panties exposed subtly as if by chance, no bra, high heels",
|
| 36 |
+
"secretary": "a provocative office pencil skirt and sheer blouse, thigh-high stockings, semi-transparent lace panties hinted at from a natural skirt shift, no bra, red high heels",
|
| 37 |
+
"teacher": "a fitted blazer over a silk blouse and short skirt, thigh-high stockings, delicate lace panties subtly visible during natural movement, no bra, classic pumps",
|
| 38 |
+
"schoolgirl": "a short pleated skirt and white blouse, thigh-high stockings, classic black lace panties slipping into view during casual poses, no bra, black loafers",
|
| 39 |
+
"lawyer": "a tailored suit with skirt cut above knees, silk blouse unbuttoned slightly, thigh-high stockings, lace panties revealed subtly when seated, no bra, leather pumps",
|
| 40 |
+
"yoga instructor": "form-fitting athletic wear that hugs curves, moisture-wicking fabric, lace panty lines subtly visible through tight clothing, sports bra barely containing",
|
| 41 |
+
"policewoman": "a fitted police uniform with short skirt, thigh-high stockings, lace panties subtly showing during action poses, no bra, polished combat boots",
|
| 42 |
+
"female military officer in gala uniform": "a ceremonial uniform with decorative elements, thigh-high stockings, lace panties hinted beneath tailored skirt, no bra, dress shoes",
|
| 43 |
+
"WWII-era secretary": "vintage styled dress with seamed stockings, lace panties from era subtly revealed when bending, no bra, period-appropriate heels",
|
| 44 |
+
"1960s flight attendant": "retro uniform with pillbox hat, thigh-high stockings, vintage lace panties subtly visible during graceful movements, no bra, classic heels",
|
| 45 |
+
"boudoir model": "silk robe falling open, thigh-high stockings, intricate lace panties prominently displayed, no bra, feathered mules",
|
| 46 |
+
"elegant judge": "judicial robes over a sophisticated dress, thigh-high stockings, luxury lace panties subtly revealed when robes part, no bra, court heels",
|
| 47 |
+
"seductive librarian": "tight sweater and pencil skirt, thigh-high stockings, lace panties subtly visible when reaching for books, no bra, reading glasses",
|
| 48 |
+
"sensual model": "designer evening gown with thigh slit, thigh-high stockings, luxury lace panties showcased during photo shoot poses, no bra, runway heels",
|
| 49 |
+
"alluring secretary": "bodycon dress and blazer, thigh-high stockings, lace panties clearly outlined beneath fabric, no bra, stiletto pumps",
|
| 50 |
+
"elegant flight attendant": "modern uniform with scarf, thigh-high stockings, lace panties subtly visible during boarding gestures, no bra, airline heels",
|
| 51 |
+
"seductive maid": "traditional french maid costume shortened, thigh-high stockings, lace panties prominently displayed during cleaning poses, no bra,mary janes",
|
| 52 |
+
"mysterious nurse": "night shift uniform with cape, thigh-high stockings, lace panties revealed during urgent movements, no bra, silent shoes",
|
| 53 |
+
"captivating schoolgirl": "a short skirt and blouse with thigh-high stockings, classic black lace panties slipping into view, no bra, black patent heels",
|
| 54 |
+
"business executive": "power suit with mini skirt, thigh-high stockings, luxury lace panties visible during confident walking, no bra, executive heels",
|
| 55 |
+
"fitness model": "performance activewear, thigh-high athletic socks, sporty lace panties outlined during exercise poses, no bra, training shoes"
|
| 56 |
+
}
|
| 57 |
+
self.POSES = [
|
| 58 |
+
"standing gracefully with one leg slightly forward, skirt adjusting as if caught in motion revealing lace panties",
|
| 59 |
+
"seated on the edge, legs crossed, skirt shifting and lace panties subtly visible",
|
| 60 |
+
"bending forward slightly as if picking something up, skirt rising to show lace panties",
|
| 61 |
+
"leaning against a wall, one hip cocked, skirt riding up to reveal lace panties",
|
| 62 |
+
"walking with a natural sway, skirt moving with motion to show glimpses of lace panties",
|
| 63 |
+
"reaching upwards for an object, skirt lifting to display lace panties",
|
| 64 |
+
"sitting on stairs, legs slightly apart, skirt providing a view of lace panties",
|
| 65 |
+
"lying on a sofa, dress falling open to reveal lace panties naturally",
|
| 66 |
+
"dancing gently, skirt flowing to show lace panties during spins",
|
| 67 |
+
"adjusting stockings, skirt lifted to expose lace panties momentarily"
|
| 68 |
+
]
|
| 69 |
+
self.SETTINGS = [
|
| 70 |
+
"a modern professional office, golden sunset light and sophisticated decor",
|
| 71 |
+
"a stylish hospital room, clean bright tones, realistic medical equipment",
|
| 72 |
+
"a luxurious bedroom with silk sheets and soft lighting",
|
| 73 |
+
"an elegant living room with vintage furniture and warm ambiance",
|
| 74 |
+
"a photography studio with professional lighting and minimalist backdrop",
|
| 75 |
+
"a high-end hotel suite with city views and contemporary design",
|
| 76 |
+
"a classic library with wooden shelves and warm reading lights",
|
| 77 |
+
"a rooftop terrace with urban landscape and twilight sky",
|
| 78 |
+
"a dressing room with large mirrors and velvet furnishings",
|
| 79 |
+
"a boutique hotel lobby with art deco elements and soft lighting"
|
| 80 |
+
]
|
| 81 |
+
self.ATMOSPHERES = [
|
| 82 |
+
"soft professional lighting with perfect color, crisp highlights and smooth skin shadows",
|
| 83 |
+
"warm ambient sunlight, rich gold reflections and depth",
|
| 84 |
+
"moody cinematic lighting with dramatic shadows and highlights",
|
| 85 |
+
"romantic candlelight with soft glows and intimate shadows",
|
| 86 |
+
"studio flash lighting with clean, sharp details and minimal shadows",
|
| 87 |
+
"golden hour natural light with warm, flattering tones",
|
| 88 |
+
"moonlit ambiance with cool tones and mysterious atmosphere",
|
| 89 |
+
"neon accent lighting with vibrant colors and urban vibe"
|
| 90 |
+
]
|
| 91 |
+
self.TECHNICAL_DETAILS = (
|
| 92 |
+
"captured with varied angles including low-angle views from knees upwards to head filling the full vertical 9:16 frame, "
|
| 93 |
+
"showcasing close-up ultra-high definition fabric, lace, skin, and hair detail, perfect makeup, anatomical perfection, elegant high heels, NO bra. "
|
| 94 |
+
"Humanized professional photorealism: Canon R5, 85mm lens, f/1.2, 16K resolution, flawless skin pores, hyper-real lace and wardrobe texture, natural human imperfections. "
|
| 95 |
+
"Exclude: cartoon, 2D, painting, stylized, CGI, illustration, lowres, watermark."
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
def _random_choice(self, lst):
|
| 99 |
+
return random.choice(lst)
|
| 100 |
+
|
| 101 |
+
def generate_prompt(self, seed: Optional[Dict[str, Any]] = None) -> str:
|
| 102 |
+
seed = seed or {}
|
| 103 |
+
role = seed.get("role", self._random_choice(self.ROLES))
|
| 104 |
+
hair_style = seed.get("hair_style", self._random_choice(self.HAIR_STYLES))
|
| 105 |
+
eye_color = seed.get("eye_color", self._random_choice(self.EYE_COLORS))
|
| 106 |
+
outfit = self.OUTFIT_TEMPLATES.get(role, self.OUTFIT_TEMPLATES["secretary"])
|
| 107 |
+
pose = seed.get("pose", self._random_choice(self.POSES))
|
| 108 |
+
setting = seed.get("setting", self._random_choice(self.SETTINGS))
|
| 109 |
+
atmosphere = seed.get("atmosphere", self._random_choice(self.ATMOSPHERES))
|
| 110 |
+
|
| 111 |
+
prompt = (
|
| 112 |
+
f"A hyperrealistic full-body portrait of a sensual {role} with {hair_style} in {eye_color} eyes, "
|
| 113 |
+
f"perfect makeup, flawless skin with subtle natural imperfections. Wearing {outfit}. "
|
| 114 |
+
f"Pose: {pose}. Scene: {setting}. Atmosphere: {atmosphere}. "
|
| 115 |
+
f"{self.TECHNICAL_DETAILS}"
|
| 116 |
+
)
|
| 117 |
+
return prompt
|
| 118 |
+
|
| 119 |
+
def generate_five_prompts(self):
|
| 120 |
+
return [self.generate_prompt() for _ in range(5)]
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def generate_prompts():
|
| 124 |
+
generator = PromptGenerator()
|
| 125 |
+
return "\n\n".join(generator.generate_five_prompts())
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
+
import gradio as gr
|
| 129 |
|
| 130 |
with gr.Blocks() as demo:
|
| 131 |
+
gr.Markdown("# Hyperrealistic Full-Body Prompt Generator")
|
| 132 |
output = gr.Textbox(label="Generated Prompts", lines=20)
|
| 133 |
+
button = gr.Button("Generate 5 Prompts")
|
| 134 |
+
button.click(fn=generate_prompts, outputs=output)
|
|
|
|
| 135 |
|
| 136 |
if __name__ == "__main__":
|
| 137 |
demo.launch()
|