Spaces:
Runtime error
Runtime error
charliealonso
commited on
Commit
•
a3e7230
1
Parent(s):
8d0d81d
Upload files
Browse files- app.py +49 -0
- shinpiden.csv +15 -0
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from contextlib import nullcontext
|
3 |
+
|
4 |
+
import csv
|
5 |
+
import random
|
6 |
+
import gradio as gr
|
7 |
+
from gradio.components import Textbox, Dropdown
|
8 |
+
|
9 |
+
def parametroAleatorio(lista):
|
10 |
+
res = random.choice(list(lista))
|
11 |
+
while res == '':
|
12 |
+
res = random.choice(list(lista))
|
13 |
+
return res
|
14 |
+
|
15 |
+
def concat_prompt(*args):
|
16 |
+
campos = {arg: valor for arg, valor in zip(csv_reader.fieldnames, args)}
|
17 |
+
choices = [campo.strip() for campo in campos.values() if campo]
|
18 |
+
|
19 |
+
for campo, valor in campos.items():
|
20 |
+
if not valor:
|
21 |
+
# Si el campo está vacío, se selecciona un valor aleatorio de la lista correspondiente
|
22 |
+
campos[campo] = parametroAleatorio(valoresUnicos[campo])
|
23 |
+
choices.append(campos[campo])
|
24 |
+
|
25 |
+
prompt = ', '.join(choices)
|
26 |
+
return prompt
|
27 |
+
|
28 |
+
with open('shinpiden.csv', 'r') as csv_file:
|
29 |
+
csv_reader = csv.DictReader(csv_file)
|
30 |
+
valoresUnicos = {}
|
31 |
+
for campo in csv_reader.fieldnames:
|
32 |
+
valoresUnicos[campo] = set()
|
33 |
+
for row in csv_reader:
|
34 |
+
for campo, valor in row.items():
|
35 |
+
valoresUnicos[campo].add(valor)
|
36 |
+
|
37 |
+
dropdowns = []
|
38 |
+
for campo, valores in valoresUnicos.items():
|
39 |
+
dropdown = Dropdown(list(valores), label=campo.capitalize())
|
40 |
+
dropdowns.append(dropdown)
|
41 |
+
|
42 |
+
output_text = Textbox(label='Prompt')
|
43 |
+
|
44 |
+
title = "Generador Prompts Midjourney"
|
45 |
+
description = '<div align="center"> Selecciona entre los distintos menús desplegables para generar un Prompt creativo, los que dejes en blanco serán elegidos aleatoriamente.</div>'
|
46 |
+
inputs = [Dropdown(list(valoresUnicos[campo]), label=campo.capitalize()) for campo in valoresUnicos.keys()]
|
47 |
+
outputs = output_text
|
48 |
+
|
49 |
+
gr.Interface(fn=concat_prompt, inputs=inputs, outputs=outputs, title=title, description=description).launch()
|
shinpiden.csv
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Imagen,Acción del usuario,Variable de color,Variable de forma,Variable de elemento central,Variable de texto,Aspect Ratio
|
2 |
+
Cinematic shot ,Attending a sound healing session," Warm tones (oranges, yellows, reds)",A central circle with waves of light,An image of a person meditating,Healing from within,--ar 1:1
|
3 |
+
"Editorial photo, ",Learning meditation techniques," Cool tones (blues, purples, greens)", A heart with rays of light, An image of a quartz crystal, Opening the heart,--ar 2:3
|
4 |
+
,Participating in a mindfulness workshop," Natural shades (earth, brown, moss green)", A spiral with sparks of light, An image of a lighted candle, Connecting with energy,
|
5 |
+
,Attending a yoga retreat," Pastel shades (pinks, lavender, light blue)", A flower with moving petals, An image of an incense plant, Meditation for the soul,
|
6 |
+
,Exploring aromatherapy," Bright shades (fuchsia, turquoise, gold)", A tree with expanding branches, An image of a Buddha figure, Sharing love and light,
|
7 |
+
,Trying acupuncture for the first time," Dark shades (gray, black, navy blue)", A mandala with complex patterns, An image of a Reiki symbol, Discovering your balance,
|
8 |
+
,Attending a wellness conference,, A path with guiding arrows, An image of a chakra in balance, Exploring new dimensions,
|
9 |
+
,Taking a hike in nature,, A key with a ray of light, An image of a bird in flight, Rest in peace,
|
10 |
+
,Practicing breathwork techniques,,,,,
|
11 |
+
,Participating in a gratitude journaling workshop,,,,,
|
12 |
+
,Learning about herbal remedies,,,,,
|
13 |
+
,Attending a fitness bootcamp,,,,,
|
14 |
+
,Participating in a healthy cooking class,,,,,
|
15 |
+
,Exploring the benefits of essential oils,,,,,
|