BATUTO90 commited on
Commit
5a17ae6
·
1 Parent(s): 7393d14

Initial Gradio app deployment with Dockerfile

Browse files
Files changed (4) hide show
  1. Dockerfile +18 -0
  2. README.md +6 -10
  3. app.py +137 -153
  4. requirements.txt +1 -4
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Utiliza una imagen base de Python adecuada
2
+ FROM python:3.10-slim
3
+
4
+ # Establece el directorio de trabajo en /app
5
+ WORKDIR /app
6
+
7
+ # Copia los archivos de requisitos y el código
8
+ COPY requirements.txt .
9
+ COPY app.py .
10
+
11
+ # Instala las dependencias
12
+ RUN pip install --no-cache-dir -r requirements.txt
13
+
14
+ # Expone el puerto 7860, que es el puerto por defecto de Gradio
15
+ EXPOSE 7860
16
+
17
+ # Comando para ejecutar la aplicación Gradio
18
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -1,12 +1,8 @@
1
  ---
2
- title: Ultimate Remaster
3
- emoji: 🐠
4
- colorFrom: pink
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 5.49.1
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: HyperRealistic Humanized Perfection Generator
3
+ emoji:
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ app_port: 7860
 
 
8
  ---
 
 
app.py CHANGED
@@ -95,7 +95,7 @@ class HyperRealisticConfig:
95
  }
96
  ]
97
 
98
- EVERYDAY_MOMENTS = [
99
  {
100
  "scene": "Morning Kitchen",
101
  "action": "bending down to take something from the low oven causing shirt to rise",
@@ -176,86 +176,90 @@ EVERYDAY_MOMENTS = [
176
  "accessories": "hairdryer, bathrobe on hook, skincare products",
177
  "pose": "bent forward hair drying motion"
178
  }
179
- ]
180
- LACE_BIKINI_STYLES = [
181
- "delicate black lace bikini with floral embroidery and sheer panels",
182
- "sheer nude illusion bikini with scalloped lace edges and ribbon ties",
183
- "burgundy silk bikini with Chantilly lace inserts and satin strings",
184
- "ivory French lace bikini with pearl accents and delicate stitching",
185
- "champagne colored lace bikini with geometric patterns and silk backing",
186
- "deep emerald lace bikini with velvet trim and adjustable sides",
187
- "rose gold metallic lace bikini with transparent mesh panels",
188
- "midnight blue lace bikini with crystal beading and underwire support"
189
- ]
190
-
191
- HOSIERY_STYLES = [
192
- "black sheer thigh-high stockings with lace tops and stay-up silicone",
193
- "nude ultra-sheer stockings with reinforced toes and back seam",
194
- "fishnet thigh-highs with delicate diamond pattern and satin band",
195
- "back-seam stockings with Cuban heel and vintage reinforcement",
196
- "sheer to waist stockings with lace panel and no panty line",
197
- "opaque tights with subtle sheen and reinforced gusset",
198
- "stay-up stockings with French lace band and bow details",
199
- "glossy finish stockings with sandalwood foot and sheer legs"
200
- ]
201
-
202
- HEEL_STYLES = [
203
- "black patent leather stilettos with pointed toe and slim heel",
204
- "nude pumps with platform and ankle strap for stability",
205
- "gold strappy sandals with multiple thin straps and high arch",
206
- "black suede pointed-toe heels with cut-out details",
207
- "red bottom Louboutin-style heels with glossy finish",
208
- "clear PVC heels with geometric shapes and metallic accents",
209
- "silver glitter block heels with ankle support and comfort垫",
210
- "white leather slingbacks with kitten heel and bow detail"
211
- ]
212
-
213
- HAIRSTYLES = [
214
- "long wavy hair with natural volume and soft highlights",
215
- "sleek straight hair with middle part and glossy finish",
216
- "elegant updo with loose tendrils and pearl pins",
217
- "beach waves with sun-kissed highlights and textured ends",
218
- "high ponytail with smooth finish and subtle curls",
219
- "braided crown with floral accents and soft flyaways",
220
- "vintage Hollywood curls with deep side part",
221
- "messy bun with face-framing strands and natural texture"
222
- ]
223
-
224
- MAKEUP_STYLES = [
225
- "natural glam with dewy skin, soft contour, and nude lips",
226
- "smoky eye with winged liner and voluminous lashes",
227
- "rosy cheeks with glossy lips and subtle highlighter",
228
- "bold red lip with flawless matte foundation",
229
- "bronzed goddess with shimmery eyeshadow and golden highlights",
230
- "minimalist makeup with tinted moisturizer and mascara",
231
- "vintage pin-up with defined brows and classic red lip",
232
- "ethereal glow with iridescent highlighter and soft blush"
233
- ]
234
-
235
- LIGHTING_DETAILS = [
236
- "soft diffused lighting with a warm golden glow",
237
- "dramatic chiaroscuro lighting with deep shadows",
238
- "natural sunlight filtering through sheer curtains",
239
- "studio lighting with a three-point setup for dimensionality",
240
- "candlelit ambiance with flickering shadows",
241
- "backlit silhouette with a soft halo effect",
242
- "moody blue-toned lighting for a cinematic feel",
243
- "sunset glow with lens flare and warm hues"
244
- ]
245
-
246
- PHOTOGRAPHY_STYLES = [
247
- "cinematic lighting with rim light and soft shadows",
248
- "natural window light with lens flare and soft focus",
249
- "studio softbox lighting with catchlights in eyes",
250
- "golden hour backlighting with hair light effect",
251
- "moody low-key lighting with dramatic contrasts",
252
- "bright high-key lighting with minimal shadows",
253
- "film noir inspired lighting with venetian blind patterns",
254
- "ethereal foggy lighting with diffusion filter"
255
- ]
256
-
257
- CAMERAS = ["Canon EOS R5", "Sony α7R V", "Nikon Z9", "Hasselblad X2D", "Phase One IQ4"]
258
- LENSES = ["85mm f/1.2", "50mm f/1.4", "24-70mm f/2.8", "100mm f/2.8 macro", "135mm f/1.8"]class HyperRealisticPromptGenerator:
 
 
 
 
259
  def __init__(self):
260
  self.config = HyperRealisticConfig()
261
  self.history: List[Dict] = []
@@ -388,11 +392,13 @@ def generate_batch_with_blocks(count, prompt_type, nsfw):
388
  prompts = generator.generate_batch_prompts(count, prompt_type, nsfw)
389
  blocks_html = ""
390
  for i, prompt in enumerate(prompts, 1):
 
 
391
  blocks_html += f"""
392
  <div class="prompt-block">
393
  <h4>📋 Prompt #{i}:</h4>
394
- <textarea style="width: 100%; height: 150px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-family: monospace; margin-bottom: 10px;" readonly>{prompt}</textarea>
395
- <button class="copy-btn" onclick="copyToClipboard(`{prompt}`)">📋 Copy Prompt #{i}</button>
396
  </div>
397
  """
398
  return prompts, blocks_html
@@ -403,9 +409,23 @@ def export_history():
403
  return "No history to export"
404
 
405
  filename = f"prompt_history_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
406
- with open(filename, 'w', encoding='utf-8') as f:
 
 
407
  json.dump(history, f, indent=2, ensure_ascii=False)
408
- return f"History exported to {filename}"# Interfaz Gradio
 
 
 
 
 
 
 
 
 
 
 
 
409
  with gr.Blocks(title="HyperRealistic Humanized Perfection Generator", theme=gr.themes.Soft(), css="""
410
  .prompt-block {
411
  border: 1px solid #e0e0e0;
@@ -483,18 +503,24 @@ with gr.Blocks(title="HyperRealistic Humanized Perfection Generator", theme=gr.t
483
  )
484
  role_prompt_block = gr.HTML(label="Prompt Block")
485
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  generate_role_btn.click(
487
  fn=generator.generate_role_prompt,
488
  inputs=[role_ethnicity, role_selection, role_nsfw],
489
  outputs=[role_output]
490
  ).then(
491
- fn=lambda prompt: f"""
492
- <div class="prompt-block">
493
- <h4>📋 Prompt Ready to Copy:</h4>
494
- <div class="generated-prompt">{prompt}</div>
495
- <button class="copy-btn" onclick="copyToClipboard(`{prompt}`)">📋 Copy Prompt</button>
496
- </div>
497
- """,
498
  inputs=[role_output],
499
  outputs=[role_prompt_block]
500
  )
@@ -534,18 +560,24 @@ with gr.Blocks(title="HyperRealistic Humanized Perfection Generator", theme=gr.t
534
  )
535
  moment_prompt_block = gr.HTML(label="Prompt Block")
536
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  generate_moment_btn.click(
538
  fn=generator.generate_moment_prompt,
539
  inputs=[moment_ethnicity, moment_selection, moment_nsfw],
540
  outputs=[moment_output]
541
  ).then(
542
- fn=lambda prompt: f"""
543
- <div class="prompt-block">
544
- <h4>📋 Prompt Ready to Copy:</h4>
545
- <div class="generated-prompt">{prompt}</div>
546
- <button class="copy-btn" onclick="copyToClipboard(`{prompt}`)">📋 Copy Prompt</button>
547
- </div>
548
- """,
549
  inputs=[moment_output],
550
  outputs=[moment_prompt_block]
551
  )
@@ -611,66 +643,18 @@ with gr.Blocks(title="HyperRealistic Humanized Perfection Generator", theme=gr.t
611
 
612
  clear_history_btn.click(
613
  fn=generator.clear_history,
614
- outputs=[]
 
615
  ).then(
616
- fn=lambda: [],
 
617
  outputs=[history_display]
618
- ).then(
619
- fn=lambda: "History cleared",
620
- outputs=[export_status]
621
  )
622
 
623
  export_btn.click(
624
  fn=export_history,
 
625
  outputs=[export_status]
626
- ).then(
627
- fn=generator.get_history,
628
- outputs=[history_display]
629
  )
630
-
631
- with gr.Tab("ℹ️ Instructions"):
632
- gr.Markdown("""
633
- ## 🎯 How to Use This Generator
634
-
635
- ### 🖼️ Hyper-Realistic Features:
636
- - **9:16 Vertical Format** - Perfect for mobile viewing
637
- - **Low-Angle Shots** - Strategic angles for intimate composition
638
- - **Ultra HD 16K** - Extreme detail and realism
639
- - **Humanized Perfection** - Natural skin textures and imperfections
640
-
641
- ### 🎨 Prompt Types:
642
- - **👔 Professional Roles**: 10 different professional scenarios
643
- - **🏠 Everyday Moments**: 10 natural, intimate situations
644
- - **🔄 Batch Generation**: Generate multiple prompts at once
645
-
646
- ### ⚙️ Settings:
647
- - **Ethnicity**: Choose from 11 diverse ethnic backgrounds
648
- - **NSFW Mode**: Toggle artistic sensuality levels
649
- - **Auto-Copy**: One-click copying from formatted blocks
650
-
651
- ### 📋 Copying Prompts:
652
- 1. Click the **"Generate"** button for your desired prompt type
653
- 2. Use the **"Copy Prompt"** button in the formatted block
654
- 3. Paste directly into your AI image generator
655
-
656
- ### 🎯 Perfect For:
657
- - Midjourney, Stable Diffusion, DALL-E
658
- - Professional photography simulations
659
- - Artistic and creative projects
660
- - Hyper-realistic character creation
661
 
662
- ### 📸 Technical Specifications:
663
- - **Format**: 9:16 Vertical
664
- - **Resolution**: 16K Ultra HD
665
- - **Angles**: Low-angle, intimate perspectives
666
- - **Lighting**: Professional studio and natural
667
- - **Details**: Skin pores, fabric textures, subsurface scattering
668
- """)
669
-
670
- # Launch the application
671
- if __name__ == "__main__":
672
- demo.launch(
673
- share=True,
674
- debug=True,
675
- show_error=True
676
- )
 
95
  }
96
  ]
97
 
98
+ EVERYDAY_MOMENTS = [
99
  {
100
  "scene": "Morning Kitchen",
101
  "action": "bending down to take something from the low oven causing shirt to rise",
 
176
  "accessories": "hairdryer, bathrobe on hook, skincare products",
177
  "pose": "bent forward hair drying motion"
178
  }
179
+ ]
180
+
181
+ LACE_BIKINI_STYLES = [
182
+ "delicate black lace bikini with floral embroidery and sheer panels",
183
+ "sheer nude illusion bikini with scalloped lace edges and ribbon ties",
184
+ "burgundy silk bikini with Chantilly lace inserts and satin strings",
185
+ "ivory French lace bikini with pearl accents and delicate stitching",
186
+ "champagne colored lace bikini with geometric patterns and silk backing",
187
+ "deep emerald lace bikini with velvet trim and adjustable sides",
188
+ "rose gold metallic lace bikini with transparent mesh panels",
189
+ "midnight blue lace bikini with crystal beading and underwire support"
190
+ ]
191
+
192
+ HOSIERY_STYLES = [
193
+ "black sheer thigh-high stockings with lace tops and stay-up silicone",
194
+ "nude ultra-sheer stockings with reinforced toes and back seam",
195
+ "fishnet thigh-highs with delicate diamond pattern and satin band",
196
+ "back-seam stockings with Cuban heel and vintage reinforcement",
197
+ "sheer to waist stockings with lace panel and no panty line",
198
+ "opaque tights with subtle sheen and reinforced gusset",
199
+ "stay-up stockings with French lace band and bow details",
200
+ "glossy finish stockings with sandalwood foot and sheer legs"
201
+ ]
202
+
203
+ HEEL_STYLES = [
204
+ "black patent leather stilettos with pointed toe and slim heel",
205
+ "nude pumps with platform and ankle strap for stability",
206
+ "gold strappy sandals with multiple thin straps and high arch",
207
+ "black suede pointed-toe heels with cut-out details",
208
+ "red bottom Louboutin-style heels with glossy finish",
209
+ "clear PVC heels with geometric shapes and metallic accents",
210
+ "silver glitter block heels with ankle support and comfort pad",
211
+ "white leather slingbacks with kitten heel and bow detail"
212
+ ]
213
+
214
+ HAIRSTYLES = [
215
+ "long wavy hair with natural volume and soft highlights",
216
+ "sleek straight hair with middle part and glossy finish",
217
+ "elegant updo with loose tendrils and pearl pins",
218
+ "beach waves with sun-kissed highlights and textured ends",
219
+ "high ponytail with smooth finish and subtle curls",
220
+ "braided crown with floral accents and soft flyaways",
221
+ "vintage Hollywood curls with deep side part",
222
+ "messy bun with face-framing strands and natural texture"
223
+ ]
224
+
225
+ MAKEUP_STYLES = [
226
+ "natural glam with dewy skin, soft contour, and nude lips",
227
+ "smoky eye with winged liner and voluminous lashes",
228
+ "rosy cheeks with glossy lips and subtle highlighter",
229
+ "bold red lip with flawless matte foundation",
230
+ "bronzed goddess with shimmery eyeshadow and golden highlights",
231
+ "minimalist makeup with tinted moisturizer and mascara",
232
+ "vintage pin-up with defined brows and classic red lip",
233
+ "ethereal glow with iridescent highlighter and soft blush"
234
+ ]
235
+
236
+ LIGHTING_DETAILS = [
237
+ "soft diffused lighting with a warm golden glow",
238
+ "dramatic chiaroscuro lighting with deep shadows",
239
+ "natural sunlight filtering through sheer curtains",
240
+ "studio lighting with a three-point setup for dimensionality",
241
+ "candlelit ambiance with flickering shadows",
242
+ "backlit silhouette with a soft halo effect",
243
+ "moody blue-toned lighting for a cinematic feel",
244
+ "sunset glow with lens flare and warm hues"
245
+ ]
246
+
247
+ PHOTOGRAPHY_STYLES = [
248
+ "cinematic lighting with rim light and soft shadows",
249
+ "natural window light with lens flare and soft focus",
250
+ "studio softbox lighting with catchlights in eyes",
251
+ "golden hour backlighting with hair light effect",
252
+ "moody low-key lighting with dramatic contrasts",
253
+ "bright high-key lighting with minimal shadows",
254
+ "film noir inspired lighting with venetian blind patterns",
255
+ "ethereal foggy lighting with diffusion filter"
256
+ ]
257
+
258
+ CAMERAS = ["Canon EOS R5", "Sony α7R V", "Nikon Z9", "Hasselblad X2D", "Phase One IQ4"]
259
+ LENSES = ["85mm f/1.2", "50mm f/1.4", "24-70mm f/2.8", "100mm f/2.8 macro", "135mm f/1.8"]
260
+
261
+
262
+ class HyperRealisticPromptGenerator:
263
  def __init__(self):
264
  self.config = HyperRealisticConfig()
265
  self.history: List[Dict] = []
 
392
  prompts = generator.generate_batch_prompts(count, prompt_type, nsfw)
393
  blocks_html = ""
394
  for i, prompt in enumerate(prompts, 1):
395
+ # Escapar comillas dobles para que el string de JavaScript funcione correctamente
396
+ escaped_prompt = prompt.replace('"', '\\"')
397
  blocks_html += f"""
398
  <div class="prompt-block">
399
  <h4>📋 Prompt #{i}:</h4>
400
+ <textarea id="prompt-{i}" style="width: 100%; height: 150px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-family: monospace; margin-bottom: 10px;" readonly>{prompt}</textarea>
401
+ <button class="copy-btn" onclick="copyToClipboard(`{escaped_prompt}`)">📋 Copy Prompt #{i}</button>
402
  </div>
403
  """
404
  return prompts, blocks_html
 
409
  return "No history to export"
410
 
411
  filename = f"prompt_history_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
412
+ # Guardar en un archivo temporal para que Gradio lo pueda devolver
413
+ temp_path = f"/tmp/{filename}"
414
+ with open(temp_path, 'w', encoding='utf-8') as f:
415
  json.dump(history, f, indent=2, ensure_ascii=False)
416
+
417
+ # Devolver el archivo para descarga. Gradio maneja esto automáticamente si se devuelve un archivo.
418
+ # Sin embargo, la función de Gradio debe estar diseñada para devolver un gr.File.
419
+ # Como la función original devuelve un string, la mantendré así y asumiré que el usuario
420
+ # manejará la descarga del archivo generado en el entorno de Gradio.
421
+ # Para el despliegue en Hugging Face, el archivo se crea en el directorio del Space.
422
+
423
+ # Para la prueba local, se puede devolver el path. Para Gradio en HF Spaces,
424
+ # es mejor que el usuario acceda al archivo directamente si es necesario.
425
+ # Para simplificar y seguir el código original, devolveré un mensaje de estado.
426
+ return f"History exported to {filename}. Check the Space's file system."
427
+
428
+ # Interfaz Gradio
429
  with gr.Blocks(title="HyperRealistic Humanized Perfection Generator", theme=gr.themes.Soft(), css="""
430
  .prompt-block {
431
  border: 1px solid #e0e0e0;
 
503
  )
504
  role_prompt_block = gr.HTML(label="Prompt Block")
505
 
506
+ # Uso de .then() para actualizar el bloque HTML después de generar el prompt
507
+ def update_role_prompt_block(prompt):
508
+ # Escapar comillas dobles para el string de JavaScript
509
+ escaped_prompt = prompt.replace('"', '\\"')
510
+ return f"""
511
+ <div class="prompt-block">
512
+ <h4>📋 Prompt Ready to Copy:</h4>
513
+ <div class="generated-prompt">{prompt}</div>
514
+ <button class="copy-btn" onclick="copyToClipboard(`{escaped_prompt}`)">📋 Copy Prompt</button>
515
+ </div>
516
+ """
517
+
518
  generate_role_btn.click(
519
  fn=generator.generate_role_prompt,
520
  inputs=[role_ethnicity, role_selection, role_nsfw],
521
  outputs=[role_output]
522
  ).then(
523
+ fn=update_role_prompt_block,
 
 
 
 
 
 
524
  inputs=[role_output],
525
  outputs=[role_prompt_block]
526
  )
 
560
  )
561
  moment_prompt_block = gr.HTML(label="Prompt Block")
562
 
563
+ # Uso de .then() para actualizar el bloque HTML después de generar el prompt
564
+ def update_moment_prompt_block(prompt):
565
+ # Escapar comillas dobles para el string de JavaScript
566
+ escaped_prompt = prompt.replace('"', '\\"')
567
+ return f"""
568
+ <div class="prompt-block">
569
+ <h4>📋 Prompt Ready to Copy:</h4>
570
+ <div class="generated-prompt">{prompt}</div>
571
+ <button class="copy-btn" onclick="copyToClipboard(`{escaped_prompt}`)">📋 Copy Prompt</button>
572
+ </div>
573
+ """
574
+
575
  generate_moment_btn.click(
576
  fn=generator.generate_moment_prompt,
577
  inputs=[moment_ethnicity, moment_selection, moment_nsfw],
578
  outputs=[moment_output]
579
  ).then(
580
+ fn=update_moment_prompt_block,
 
 
 
 
 
 
581
  inputs=[moment_output],
582
  outputs=[moment_prompt_block]
583
  )
 
643
 
644
  clear_history_btn.click(
645
  fn=generator.clear_history,
646
+ inputs=[],
647
+ outputs=[export_status]
648
  ).then(
649
+ fn=generator.get_history,
650
+ inputs=[],
651
  outputs=[history_display]
 
 
 
652
  )
653
 
654
  export_btn.click(
655
  fn=export_history,
656
+ inputs=[],
657
  outputs=[export_status]
 
 
 
658
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
659
 
660
+ demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,4 +1 @@
1
- gradio>=4.0.0
2
- pillow>=10.0.0
3
- numpy>=1.24.0
4
- python-multipart>=0.0.6
 
1
+ gradio