ivanoctaviogaitansantos commited on
Commit
1df72d8
·
verified ·
1 Parent(s): e5d6522

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +117 -90
app.py CHANGED
@@ -31,102 +31,128 @@ def analyze_python_code(code: str) -> str:
31
  tools = [analyze_python_code]
32
 
33
  # Inicializa el agente con herramientas y modelo
34
- # CORRECCIÓN APLICADA: Se establece add_base_tools=False para evitar el error de dependencia 'ddgs'.
35
  agent = CodeAgent(
36
  tools=tools,
37
  model=model,
38
  add_base_tools=False
39
  )
40
 
41
- # DATOS PARA GENERACIÓN DE PERSONAJES INVENTADOS (Mínimo 5 elementos para muestreo único)
42
  FICTIONAL_ROLES = [
43
- "Cyber Priestess", "Shadow Weaver", "Neo-Viking Huntress", "Aetherpunk Alchemist",
44
- "Galactic Rogue", "Urban Shaman", "Silent Assassin", "Chrononaut Captain", "Arcane Detective", "Desert Nomad"
45
  ]
46
  HAIR_STYLES = [
47
- "long, braided white hair", "short, messy fluorescent green hair", "sleek, silver bun with neon accents",
48
- "crimson dreadlocks", "wavy black hair with blue tips", "voluminous golden curls", "asymmetrical pink bob",
49
- "shaved head with glowing runes", "icy blue waterfall hair", "dark purple pigtails"
50
  ]
 
51
  OUTFIT_THEMES = [
52
- "a tattered military jacket and tactical gear", "a flowing silk kimono with metallic accents",
53
- "an asymmetrical leather coat and utility harness", "a delicate, bioluminescent gown",
54
- "a streamlined obsidian suit with glowing pipes", "a distressed denim outfit with heavy chains",
55
- "a high-collared velvet cape and ornate gloves", "a minimalist carbon-fiber bodysuit",
56
- "weathered bronze armor with tribal markings", "a torn, ethereal school uniform"
 
57
  ]
58
- EYE_COLORS = ["gold", "iridescent blue", "vibrant purple", "deep emerald green", "flaming orange", "silver", "pale white", "ruby red", "electric yellow", "magenta"]
59
-
60
 
 
61
  SETTINGS = [
62
- "neon-lit office at midnight with hum of computers and scent of rain",
63
- "gothic library filled with flickering candlelight and faded parchment scent",
64
- "throne room bathed in warm golden light with velvet drapes",
65
- "sterile operating room with bright surgical lights and soft beeping sounds",
66
- "magical forest with glowing flora and gentle breeze rustling leaves"
 
67
  ]
68
 
 
69
  ACTIVITIES = [
70
- "reaching for a top-shelf file",
71
- "arranging occult tomes on a desk",
72
- "casting a subtle spell with glowing magical effects",
73
- "serving coffee with graceful movements",
74
- "walking confidently down a gothic hallway"
 
75
  ]
76
 
77
  LINGERIE_COLORS = ["black", "red", "white", "navy blue", "deep burgundy"]
78
  STOCKING_DETAILS = ["a delicate back seam", "intricate lace pattern", "classic fishnet design", "smooth satin finish", "subtle floral embroidery"]
79
  HEEL_DETAILS = ["sharp stiletto heels", "elegant kitten heels", "strappy high heels", "sleek patent leather pumps", "classic pointed toe heels"]
80
  POSES = ["confident stance, one hand on hip", "sitting casually on a desk", "leaning slightly forward", "standing with arms crossed", "walking with a playful smile"]
81
- EXPRESSIONS = ["a knowing, seductive smile", "a confident, alluring gaze", "a playful smirk", "an intense, focused look", "a soft, inviting smile"]
 
 
 
 
 
 
 
82
 
83
  def generate_prompt(role, hair_style, outfit_theme, eye_color, setting, activity, lingerie_color, stocking_detail, heel_detail, pose, expression, prompt_num):
84
  """
85
- Genera un prompt en formato JSON aplicando los parámetros técnicos de hiperrealismo
86
- y el estilo de fotografía editorial de alta moda con un personaje inventado.
87
  """
88
- # Construcción de la descripción base del personaje para el campo 'prompt'
89
- character_description = (
90
- f"**{role}** (Invented Character) in a hyper-realistic, high-fashion editorial photograph. "
91
- f"Full body shot (Plano entero), featuring **{hair_style}** and **{eye_color} eyes**. "
92
- f"Her main attire is **{outfit_theme}**. "
93
- f"Underneath, she is wearing **{lingerie_color} lace lingerie** (thong and bra) and thigh-high stockings with {stocking_detail}. "
94
- f"Paired with {heel_detail}. Posed in a {pose} and {expression} in a {setting}. "
95
- f"The character is {activity}."
 
 
 
 
96
  )
97
 
98
- prompt_data = {
99
- "title": f"Editorial Shoot - {role} - Prompt {prompt_num}",
100
- "metadata": {
101
- "aspect_ratio": "9:16",
102
- "shot_type": "Full-Body Shot (Plano entero)",
103
- "camera": "Hasselblad H6D-400c con 80mm f/2.8 lens",
104
- "lighting": "Rembrandt lighting, ARRI SkyPanel S360-C illumination",
105
- "aperture": "f/4 (Reduced Depth of Field)",
106
- "signature": "BATUTO'ART (Graffiti Tag, Top-Left, 5%)"
107
- },
108
- "prompt": character_description,
109
- "style_modifiers": [
110
- "High-fashion editorial photography style",
111
- "Hiper-realistic CGI by Blizzard Entertainment",
112
- "Fotografía de Alexander Nanitchkov",
113
- "Escaneado 3D de personaje AAA",
114
- "Unreal Engine 5 Ray Tracing",
115
- "Detalles epidérmicos con Mapas 8K"
116
- ],
117
- "physics_and_effects": {
118
- "physiology": "Enhanced Human Proportions (Athlete body, subtle supernatural modifications)",
119
- "texture": "Realistic skin imperfections (pores, scars, blemishes), Sub-surface scattering reflections on skin",
120
- "atmosphere": "Volumetric atmospheric smoke, Real rain droplets (scale 1:1) (if applicable to setting)",
121
- "clothing_detail": "Realistic fabric sheen, Wear and tear imperfections on clothes/props"
122
- },
123
- "negative_prompt_keywords": [
124
- "cartoon", "blurry", "pixelated", "low-resolution", "watermark", "noise", "overexposed", "underexposed",
125
- "unnatural shadows", "color banding", "oversaturation", "artificial textures", "disallowed artifacts"
126
- ]
127
- }
128
-
129
- return json.dumps(prompt_data, indent=4)
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  def chat_with_agent(user_message, history):
132
  user_message_clean = user_message.strip().lower()
@@ -138,41 +164,43 @@ def chat_with_agent(user_message, history):
138
  # Selección única de componentes para asegurar 5 PROMPTS NO REPETIDOS
139
  try:
140
  # Componentes del personaje
141
- unique_roles = random.sample(FICTIONAL_ROLES, num_prompts)
142
- unique_hair_styles = random.sample(HAIR_STYLES, num_prompts)
143
- unique_outfit_themes = random.sample(OUTFIT_THEMES, num_prompts)
144
- unique_eye_colors = random.sample(EYE_COLORS, num_prompts)
145
-
146
- # Componentes de la escena (también muestreados de forma única para máxima variación)
147
- unique_settings = random.sample(SETTINGS, num_prompts)
148
- unique_activities = random.sample(ACTIVITIES, num_prompts)
149
- unique_lingerie_colors = random.sample(LINGERIE_COLORS, num_prompts)
150
- unique_stocking_details = random.sample(STOCKING_DETAILS, num_prompts)
151
- unique_heel_details = random.sample(HEEL_DETAILS, num_prompts)
152
- unique_poses = random.sample(POSES, num_prompts)
153
- unique_expressions = random.sample(EXPRESSIONS, num_prompts)
 
154
 
155
  except ValueError as e:
156
- return history + [[user_message, f"Error: Una de las listas de componentes tiene menos de 5 elementos y no se puede generar un set único de 5 prompts. Por favor, asegúrate de que las listas tengan al menos 5 elementos. Error detallado: {e}"]]
157
 
158
 
159
  for i in range(num_prompts):
160
  # Se llama a la función con el set de componentes único para el índice 'i'
161
- prompt_json_str = generate_prompt(
162
  unique_roles[i],
163
  unique_hair_styles[i],
164
  unique_outfit_themes[i],
165
  unique_eye_colors[i],
166
  unique_settings[i],
167
  unique_activities[i],
168
- unique_lingerie_colors[i],
169
- unique_stocking_details[i],
170
- unique_heel_details[i],
171
- unique_poses[i],
172
- unique_expressions[i],
173
  i + 1
174
  )
175
- prompts.append(f"### PROMPT {i + 1} GENERADO (JSON):\n```json\n{prompt_json_str}\n```")
 
176
 
177
  return history + [[user_message, "\n\n".join(prompts)]]
178
 
@@ -182,7 +210,7 @@ def chat_with_agent(user_message, history):
182
  return history + [[user_message, analysis_result]]
183
 
184
  else:
185
- return history + [[user_message, "Por favor, escribe 'Ok' para generar cinco prompts en **formato JSON**, o 'codigo:' seguido del código Python para analizarlo y corregirlo."]]
186
 
187
  with gr.Blocks() as demo:
188
  gr.Markdown("## Generador de Prompts Hiperrealistas y Análisis de Código Python")
@@ -197,5 +225,4 @@ with gr.Blocks() as demo:
197
 
198
  if __name__ == "__main__":
199
  demo.launch(share=False)
200
-
201
 
 
31
  tools = [analyze_python_code]
32
 
33
  # Inicializa el agente con herramientas y modelo
34
+ # Se mantiene add_base_tools=False para evitar el error de dependencia 'ddgs'.
35
  agent = CodeAgent(
36
  tools=tools,
37
  model=model,
38
  add_base_tools=False
39
  )
40
 
41
+ # DATOS PARA GENERACIÓN DE PERSONAJES INVENTADOS (TEMAS DE ROL ESPECÍFICOS)
42
  FICTIONAL_ROLES = [
43
+ "Secretary", "Nurse", "Schoolgirl", "Maid", "Flight Attendant", "Nun"
 
44
  ]
45
  HAIR_STYLES = [
46
+ "long wavy auburn hair", "short, tight black bun", "blonde pigtails",
47
+ "long cascading brunette hair", "high, professional chignon", "simple black veil over long hair"
 
48
  ]
49
+ # OUTFITS REVISADOS para ser ajustados/sugerentes y acordes al rol
50
  OUTFIT_THEMES = [
51
+ "a tight pencil skirt and partially unbuttoned blouse",
52
+ "a fitted, short-hemline nurse's uniform dress",
53
+ "a classic plaid schoolgirl uniform with a short pleated skirt",
54
+ "a short black maid uniform with a tight corset and white lace apron",
55
+ "a fitted aeromoza jacket and pencil skirt",
56
+ "a severe black habit with exposed décolletage"
57
  ]
58
+ EYE_COLORS = ["gold", "iridescent blue", "vibrant purple", "deep emerald green", "flaming orange", "silver"]
 
59
 
60
+ # SETTINGS REVISADOS: Ambientes cotidianos, no Sci-Fi/Neon
61
  SETTINGS = [
62
+ "vintage wood-paneled private office with an antique desk",
63
+ "hospital examining room during a quiet moment",
64
+ "empty classroom after hours, moonlight streaming through the window",
65
+ "opulent vintage hotel suite with plush velvet furniture",
66
+ "first-class airplane cabin during a long haul flight",
67
+ "silent, dimly lit stone chapel corridor"
68
  ]
69
 
70
+ # ACTIVITIES REVISADAS: Poses que revelan la ropa interior desde ángulos bajos
71
  ACTIVITIES = [
72
+ "bending over a desk to pick up a dropped pen",
73
+ "climbing a short set of stairs, lifting the hemline slightly",
74
+ "adjusting a stocking while sitting casually on a chair",
75
+ "leaning over a counter to wipe a surface with a playful smirk",
76
+ "reaching for a top-shelf luggage compartment",
77
+ "kneeling to pray on a marble floor"
78
  ]
79
 
80
  LINGERIE_COLORS = ["black", "red", "white", "navy blue", "deep burgundy"]
81
  STOCKING_DETAILS = ["a delicate back seam", "intricate lace pattern", "classic fishnet design", "smooth satin finish", "subtle floral embroidery"]
82
  HEEL_DETAILS = ["sharp stiletto heels", "elegant kitten heels", "strappy high heels", "sleek patent leather pumps", "classic pointed toe heels"]
83
  POSES = ["confident stance, one hand on hip", "sitting casually on a desk", "leaning slightly forward", "standing with arms crossed", "walking with a playful smile"]
84
+ # EXPRESSIONS REVISADAS: Enfocadas en el deseo y contacto visual
85
+ EXPRESSIONS = [
86
+ "a knowing, seductive smile directed at the viewer",
87
+ "an intense, lustful gaze locking with the camera",
88
+ "a confident, alluring smirk and eye contact",
89
+ "a playful wink and inviting stare",
90
+ "a soft, inviting smile with direct eye contact"
91
+ ]
92
 
93
  def generate_prompt(role, hair_style, outfit_theme, eye_color, setting, activity, lingerie_color, stocking_detail, heel_detail, pose, expression, prompt_num):
94
  """
95
+ Genera un prompt en texto plano en inglés con enfoque en Low-Angle, lencería de encaje
96
+ y contacto visual seductor.
97
  """
98
+
99
+ # 1. Main prompt (Description)
100
+ main_prompt_start = "A beautiful perfect cosplay of a"
101
+ main_prompt_details = (
102
+ f"{main_prompt_start} **{role}** (Invented Character) in a hyper-realistic, high-fashion editorial photograph. "
103
+ f"Full body shot (Plano entero), **occupying the entire frame** with a perfect body proportion. "
104
+ f"Featuring **{hair_style}** and **{eye_color} eyes**. "
105
+ f"Her suggestive main attire is **{outfit_theme}**. "
106
+ f"Underneath, she is wearing a transparent **{lingerie_color} lace thong** and matching lace bra, "
107
+ f"accentuated by thigh-high stockings with {stocking_detail}. "
108
+ f"Paired with {heel_detail}. Posed in a {pose} and **{expression}** in a {setting}. "
109
+ f"The character is captured while **{activity}**.\n"
110
  )
111
 
112
+ # 2. Technical and style modifiers
113
+ style_modifiers = [
114
+ "High-fashion editorial photography style",
115
+ "Hiper-realistic CGI by Blizzard Entertainment",
116
+ "Fotografía de Alexander Nanitchkov",
117
+ "Escaneado 3D de personaje AAA",
118
+ "Unreal Engine 5 Ray Tracing",
119
+ "Detalles epidérmicos con Mapas 8K"
120
+ ]
121
+
122
+ # 3. Physics and Effects
123
+ # La fisiología se mantiene perfecta, pero se elimina la atmósfera sci-fi/neon
124
+ physics_effects = [
125
+ "Physiology: Enhanced Human Proportions (Athlete body, subtle supernatural modifications)",
126
+ "Texture: Realistic skin imperfections (pores, scars, blemishes), Sub-surface scattering reflections on skin",
127
+ "Clothing: Realistic fabric sheen, Wear and tear imperfections on clothes/props"
128
+ ]
129
+
130
+ # 4. Negative prompt (coalesced)
131
+ negative_prompt_keywords = [
132
+ "cartoon", "blurry", "pixelated", "low-resolution", "watermark", "noise", "overexposed", "underexposed",
133
+ "unnatural shadows", "color banding", "oversaturation", "artificial textures", "disallowed artifacts"
134
+ ]
135
+
136
+ # 5. Combining all parts into a cohesive text block
137
+ final_text = (
138
+ f"PROMPT {prompt_num} (Title: Editorial Shoot - {role}):\n\n"
139
+ f"{main_prompt_details}\n"
140
+ f"--- METADATA & ANGLES ---\n"
141
+ f"Aspect Ratio: 9:16. Shot Type: Full-Body Shot (Plano entero) - **Low-Angle (Worm's Eye View)**.\n"
142
+ f"Angle Focus: Shot from a very low position looking upward, creating visual lines toward the underwear area.\n"
143
+ f"Camera: Hasselblad H6D-400c with 80mm f/2.8 lens. Aperture: f/4 (Reduced Depth of Field).\n"
144
+ f"Lighting: Rembrandt lighting, ARRI SkyPanel S360-C illumination. Selective depth of field focusing on the area of interest.\n\n"
145
+ f"--- STYLES & REFERENCES ---\n"
146
+ f"{', '.join(style_modifiers)}\n\n"
147
+ f"--- PHYSICS & DETAILING ---\n"
148
+ f"{' | '.join(physics_effects)}\n\n"
149
+ f"--- NEGATIVE PROMPT ---\n"
150
+ f"Exclude: {', '.join(negative_prompt_keywords)}\n\n"
151
+ f"--- SIGNATURE ---\n"
152
+ f"Signature Tag: BATUTO'ART (Graffiti Tag, Top-Left, 5%)"
153
+ )
154
+
155
+ return final_text
156
 
157
  def chat_with_agent(user_message, history):
158
  user_message_clean = user_message.strip().lower()
 
164
  # Selección única de componentes para asegurar 5 PROMPTS NO REPETIDOS
165
  try:
166
  # Componentes del personaje
167
+ # Usamos min(6, len(LISTA)) para garantizar que no falle si se reduce la lista de datos.
168
+ unique_roles = random.sample(FICTIONAL_ROLES, min(num_prompts, len(FICTIONAL_ROLES)))
169
+ unique_hair_styles = random.sample(HAIR_STYLES, min(num_prompts, len(HAIR_STYLES)))
170
+ unique_outfit_themes = random.sample(OUTFIT_THEMES, min(num_prompts, len(OUTFIT_THEMES)))
171
+ unique_eye_colors = random.sample(EYE_COLORS, min(num_prompts, len(EYE_COLORS)))
172
+
173
+ # Componentes de la escena
174
+ unique_settings = random.sample(SETTINGS, min(num_prompts, len(SETTINGS)))
175
+ unique_activities = random.sample(ACTIVITIES, min(num_prompts, len(ACTIVITIES)))
176
+ unique_lingerie_colors = random.sample(LINGERIE_COLORS, min(num_prompts, len(LINGERIE_COLORS)))
177
+ unique_stocking_details = random.sample(STOCKING_DETAILS, min(num_prompts, len(STOCKING_DETAILS)))
178
+ unique_heel_details = random.sample(HEEL_DETAILS, min(num_prompts, len(HEEL_DETAILS)))
179
+ unique_poses = random.sample(POSES, min(num_prompts, len(POSES)))
180
+ unique_expressions = random.sample(EXPRESSIONS, min(num_prompts, len(EXPRESSIONS)))
181
 
182
  except ValueError as e:
183
+ return history + [[user_message, f"Error: Una de las listas de componentes tiene menos de {num_prompts} elementos y no se puede generar un set único de 5 prompts. Por favor, asegúrate de que las listas tengan al menos {num_prompts} elementos. Error detallado: {e}"]]
184
 
185
 
186
  for i in range(num_prompts):
187
  # Se llama a la función con el set de componentes único para el índice 'i'
188
+ prompt_text = generate_prompt(
189
  unique_roles[i],
190
  unique_hair_styles[i],
191
  unique_outfit_themes[i],
192
  unique_eye_colors[i],
193
  unique_settings[i],
194
  unique_activities[i],
195
+ unique_lingerie_colors[i % len(LINGERIE_COLORS)], # Usar módulo para listas más cortas
196
+ unique_stocking_details[i % len(STOCKING_DETAILS)],
197
+ unique_heel_details[i % len(HEEL_DETAILS)],
198
+ unique_poses[i % len(POSES)],
199
+ unique_expressions[i % len(EXPRESSIONS)],
200
  i + 1
201
  )
202
+ # Se envuelve la salida de texto plano en un bloque de código monoscape
203
+ prompts.append(f"\n```\n{prompt_text}\n```")
204
 
205
  return history + [[user_message, "\n\n".join(prompts)]]
206
 
 
210
  return history + [[user_message, analysis_result]]
211
 
212
  else:
213
+ return history + [[user_message, "Por favor, escribe 'Ok' para generar cinco prompts en **formato de texto plano monoscape**, o 'codigo:' seguido del código Python para analizarlo y corregirlo."]]
214
 
215
  with gr.Blocks() as demo:
216
  gr.Markdown("## Generador de Prompts Hiperrealistas y Análisis de Código Python")
 
225
 
226
  if __name__ == "__main__":
227
  demo.launch(share=False)
 
228