JeCabrera commited on
Commit
f857521
·
verified ·
1 Parent(s): 96319d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -30
app.py CHANGED
@@ -57,20 +57,29 @@ def query(prompt, is_negative=False, steps=30, cfg_scale=7, strength=0.7):
57
  print(f"Error when trying to open the image: {e}")
58
  return None
59
 
 
 
 
 
 
 
 
 
 
60
  css = """
61
  #app-container {
62
- max-width: 100%; /* Ancho máximo del contenedor en 100% del espacio disponible */
63
- margin: 0 auto; /* Centrar el contenedor */
64
- padding: 20px; /* Espacio interno */
65
  }
66
 
67
  input, textarea, select {
68
- background-color: #f5f5f5; /* Fondo gris claro para inputs */
69
- color: #333333; /* Texto gris oscuro en inputs */
70
- border: 1px solid #cccccc; /* Borde gris claro en inputs */
71
- width: calc(100% - 40px); /* Ancho completo menos espacio para el botón */
72
- box-sizing: border-box; /* Incluir el borde en el ancho total */
73
- padding-right: 40px; /* Espacio para el botón de borrar */
74
  }
75
 
76
  input[type="text"] {
@@ -78,7 +87,7 @@ input[type="text"] {
78
  }
79
 
80
  input[type="text"]::after {
81
- content: "✕"; /* Símbolo de borrar */
82
  position: absolute;
83
  right: 10px;
84
  top: 50%;
@@ -88,53 +97,53 @@ input[type="text"]::after {
88
  }
89
 
90
  button {
91
- background-color: #f5f5f5; /* Fondo gris claro */
92
- color: #333333; /* Texto gris oscuro */
93
- border: 1px solid black; /* Borde negro en botones */
94
- width: 100%; /* Ancho completo del botón */
95
- box-sizing: border-box; /* Incluir el borde en el ancho total */
96
- padding: 10px; /* Espacio interno en el botón */
97
  }
98
 
99
  button.primary {
100
- background-color: green; /* Fondo verde para el botón 'Generate' */
101
- color: black; /* Texto negro en el botón 'Generate' */
102
  }
103
 
104
  button.secondary {
105
- background-color: #f5f5f5; /* Fondo gris claro para el botón 'Clear' */
106
- color: #333333; /* Texto gris oscuro en el botón 'Clear' */
107
  }
108
 
109
  button:hover {
110
- background-color: #e0e0e0; /* Fondo gris más oscuro en hover */
111
  }
112
 
113
  h1, h2, h3, h4, h5, h6 {
114
- color: #333333; /* Texto gris oscuro en encabezados */
115
  }
116
 
117
  @media (max-width: 768px) {
118
  .button-container {
119
  display: flex;
120
  flex-direction: column;
121
- align-items: center; /* Centra el botón en vista móvil */
122
  }
123
 
124
  .button-container button {
125
- width: auto; /* Ajusta el ancho del botón para móviles */
126
- margin-top: 10px; /* Espacio superior para el botón en móviles */
127
  }
128
  }
129
 
130
  @media (min-width: 769px) {
131
  .button-container {
132
  display: flex;
133
- justify-content: flex-end; /* Alinea el botón a la derecha en vista de escritorio */
134
  }
135
 
136
  .button-container button {
137
- width: auto; /* Ajusta el ancho del botón para escritorio */
138
  }
139
  }
140
  """
@@ -192,16 +201,16 @@ with gr.Blocks(css=css) as app:
192
  step=0.001
193
  )
194
 
195
- # Mover el componente de ejemplos aquí, justo debajo de Opciones Avanzadas
196
  gr.Examples(examples=examples, inputs=text_prompt, label="Ejemplos de otros sueños")
197
 
198
  with gr.Row(elem_id="button-container"):
199
  generate_button = gr.Button("QUIERO VER MI SUEÑO", elem_id="generate-button", variant="primary")
200
- reset_button = gr.HTML('<button id="reset-button" style="width: 100%; padding: 10px; background-color: #f5f5f5; color: #333; border: 1px solid black; cursor: pointer;">REINICIAR MI SUEÑO</button>')
201
-
202
  with gr.Column(scale=1):
203
  image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
204
 
205
  generate_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, strength], outputs=image_output)
 
206
 
207
  app.launch(show_api=False, share=False)
 
57
  print(f"Error when trying to open the image: {e}")
58
  return None
59
 
60
+ def reset_prompt():
61
+ default_text_prompt = "" # Valor por defecto para el campo de texto
62
+ default_negative_prompt = "(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos" # Valor por defecto para el campo de texto negativo
63
+ default_steps = 35 # Valor por defecto para el slider de pasos de muestreo
64
+ default_cfg = 7 # Valor por defecto para el slider de nivel de detalle
65
+ default_strength = 0.7 # Valor por defecto para el slider de fuerza de transformación
66
+
67
+ return default_text_prompt, default_negative_prompt, default_steps, default_cfg, default_strength
68
+
69
  css = """
70
  #app-container {
71
+ max-width: 100%;
72
+ margin: 0 auto;
73
+ padding: 20px;
74
  }
75
 
76
  input, textarea, select {
77
+ background-color: #f5f5f5;
78
+ color: #333333;
79
+ border: 1px solid #cccccc;
80
+ width: calc(100% - 40px);
81
+ box-sizing: border-box;
82
+ padding-right: 40px;
83
  }
84
 
85
  input[type="text"] {
 
87
  }
88
 
89
  input[type="text"]::after {
90
+ content: "✕";
91
  position: absolute;
92
  right: 10px;
93
  top: 50%;
 
97
  }
98
 
99
  button {
100
+ background-color: #f5f5f5;
101
+ color: #333333;
102
+ border: 1px solid black;
103
+ width: 100%;
104
+ box-sizing: border-box;
105
+ padding: 10px;
106
  }
107
 
108
  button.primary {
109
+ background-color: green;
110
+ color: black;
111
  }
112
 
113
  button.secondary {
114
+ background-color: #f5f5f5;
115
+ color: #333333;
116
  }
117
 
118
  button:hover {
119
+ background-color: #e0e0e0;
120
  }
121
 
122
  h1, h2, h3, h4, h5, h6 {
123
+ color: #333333;
124
  }
125
 
126
  @media (max-width: 768px) {
127
  .button-container {
128
  display: flex;
129
  flex-direction: column;
130
+ align-items: center;
131
  }
132
 
133
  .button-container button {
134
+ width: auto;
135
+ margin-top: 10px;
136
  }
137
  }
138
 
139
  @media (min-width: 769px) {
140
  .button-container {
141
  display: flex;
142
+ justify-content: flex-end;
143
  }
144
 
145
  .button-container button {
146
+ width: auto;
147
  }
148
  }
149
  """
 
201
  step=0.001
202
  )
203
 
 
204
  gr.Examples(examples=examples, inputs=text_prompt, label="Ejemplos de otros sueños")
205
 
206
  with gr.Row(elem_id="button-container"):
207
  generate_button = gr.Button("QUIERO VER MI SUEÑO", elem_id="generate-button", variant="primary")
208
+ reset_button = gr.Button("REINICIAR MI SUEÑO", elem_id="reset-button", variant="secondary")
209
+
210
  with gr.Column(scale=1):
211
  image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
212
 
213
  generate_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, strength], outputs=image_output)
214
+ reset_button.click(reset_prompt, outputs=[text_prompt, negative_prompt, steps, cfg, strength])
215
 
216
  app.launch(show_api=False, share=False)