Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ API_TOKEN = os.getenv("HF_READ_TOKEN")
|
|
13 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
14 |
timeout = 100
|
15 |
|
16 |
-
def query(prompt, is_negative=False, steps=30, cfg_scale=7,
|
17 |
if not prompt:
|
18 |
return None
|
19 |
|
@@ -76,10 +76,9 @@ button {
|
|
76 |
background-color: #f5f5f5; /* Fondo gris claro */
|
77 |
color: #333333; /* Texto gris oscuro */
|
78 |
border: 1px solid black; /* Borde negro en botones */
|
79 |
-
width:
|
80 |
box-sizing: border-box; /* Incluir el borde en el ancho total */
|
81 |
padding: 10px; /* Espacio interno en el bot贸n */
|
82 |
-
margin-right: 10px; /* Espacio entre los botones */
|
83 |
}
|
84 |
|
85 |
button.primary {
|
@@ -104,46 +103,24 @@ h1, h2, h3, h4, h5, h6 {
|
|
104 |
.button-container {
|
105 |
display: flex;
|
106 |
flex-direction: column;
|
107 |
-
align-items: center; /* Centra
|
108 |
}
|
109 |
|
110 |
.button-container button {
|
111 |
width: auto; /* Ajusta el ancho del bot贸n para m贸viles */
|
112 |
-
margin-top: 10px; /* Espacio superior para
|
113 |
-
}
|
114 |
-
|
115 |
-
.radio-group {
|
116 |
-
display: flex;
|
117 |
-
flex-direction: column; /* Ajusta los botones de radio en una columna */
|
118 |
-
align-items: flex-start; /* Alinea los botones a la izquierda */
|
119 |
-
}
|
120 |
-
|
121 |
-
.radio-group label {
|
122 |
-
margin-bottom: 10px; /* Espacio entre los botones de radio */
|
123 |
-
font-size: 16px; /* Tama帽o de fuente m谩s grande para m贸viles */
|
124 |
}
|
125 |
}
|
126 |
|
127 |
@media (min-width: 769px) {
|
128 |
.button-container {
|
129 |
display: flex;
|
130 |
-
justify-content: flex-end; /* Alinea
|
131 |
}
|
132 |
|
133 |
.button-container button {
|
134 |
width: auto; /* Ajusta el ancho del bot贸n para escritorio */
|
135 |
}
|
136 |
-
|
137 |
-
.radio-group {
|
138 |
-
display: flex;
|
139 |
-
flex-direction: row; /* Ajusta los botones de radio en una fila */
|
140 |
-
justify-content: space-between; /* Espacio entre los botones de radio */
|
141 |
-
}
|
142 |
-
|
143 |
-
.radio-group label {
|
144 |
-
margin-right: 20px; /* Espacio entre los botones de radio */
|
145 |
-
font-size: 18px; /* Tama帽o de fuente para escritorio */
|
146 |
-
}
|
147 |
}
|
148 |
"""
|
149 |
|
@@ -167,7 +144,8 @@ with gr.Blocks(css=css) as app:
|
|
167 |
label="驴Cu谩l fue tu sue帽o?",
|
168 |
placeholder="Describe lo que so帽aste, no omitas ning煤n detalle.",
|
169 |
lines=2,
|
170 |
-
elem_id="prompt-text-input"
|
|
|
171 |
)
|
172 |
|
173 |
with gr.Accordion("Opciones Avanzadas", open=False):
|
@@ -192,12 +170,6 @@ with gr.Blocks(css=css) as app:
|
|
192 |
maximum=20,
|
193 |
step=1
|
194 |
)
|
195 |
-
method = gr.Radio(
|
196 |
-
label="Estilo de sue帽o (M茅todo de muestreo)",
|
197 |
-
value="DPM++ 2M Karras",
|
198 |
-
choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"],
|
199 |
-
elem_id="sampling-method-radio"
|
200 |
-
)
|
201 |
strength = gr.Slider(
|
202 |
label="Intensidad del sue帽o (Fuerza de transformaci贸n)",
|
203 |
value=0.7,
|
@@ -206,16 +178,15 @@ with gr.Blocks(css=css) as app:
|
|
206 |
step=0.001
|
207 |
)
|
208 |
|
|
|
209 |
gr.Examples(examples=examples, inputs=text_prompt)
|
210 |
|
211 |
with gr.Row(elem_id="button-container"):
|
212 |
generate_button = gr.Button("QUIERO VER MI SUE脩O", elem_id="generate-button", variant="primary")
|
213 |
-
clear_button = gr.Button("Clear", elem_id="clear-button", variant="secondary")
|
214 |
|
215 |
with gr.Column(scale=1):
|
216 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
217 |
|
218 |
-
generate_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg,
|
219 |
-
clear_button.click(lambda: text_prompt.update(value=""), outputs=text_prompt)
|
220 |
|
221 |
app.launch(show_api=False, share=False)
|
|
|
13 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
14 |
timeout = 100
|
15 |
|
16 |
+
def query(prompt, is_negative=False, steps=30, cfg_scale=7, strength=0.7):
|
17 |
if not prompt:
|
18 |
return None
|
19 |
|
|
|
76 |
background-color: #f5f5f5; /* Fondo gris claro */
|
77 |
color: #333333; /* Texto gris oscuro */
|
78 |
border: 1px solid black; /* Borde negro en botones */
|
79 |
+
width: 100%; /* Ancho completo del bot贸n */
|
80 |
box-sizing: border-box; /* Incluir el borde en el ancho total */
|
81 |
padding: 10px; /* Espacio interno en el bot贸n */
|
|
|
82 |
}
|
83 |
|
84 |
button.primary {
|
|
|
103 |
.button-container {
|
104 |
display: flex;
|
105 |
flex-direction: column;
|
106 |
+
align-items: center; /* Centra el bot贸n en vista m贸vil */
|
107 |
}
|
108 |
|
109 |
.button-container button {
|
110 |
width: auto; /* Ajusta el ancho del bot贸n para m贸viles */
|
111 |
+
margin-top: 10px; /* Espacio superior para el bot贸n en m贸viles */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
113 |
}
|
114 |
|
115 |
@media (min-width: 769px) {
|
116 |
.button-container {
|
117 |
display: flex;
|
118 |
+
justify-content: flex-end; /* Alinea el bot贸n a la derecha en vista de escritorio */
|
119 |
}
|
120 |
|
121 |
.button-container button {
|
122 |
width: auto; /* Ajusta el ancho del bot贸n para escritorio */
|
123 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
"""
|
126 |
|
|
|
144 |
label="驴Cu谩l fue tu sue帽o?",
|
145 |
placeholder="Describe lo que so帽aste, no omitas ning煤n detalle.",
|
146 |
lines=2,
|
147 |
+
elem_id="prompt-text-input",
|
148 |
+
show_clear_button=True # Bot贸n de borrar visible
|
149 |
)
|
150 |
|
151 |
with gr.Accordion("Opciones Avanzadas", open=False):
|
|
|
170 |
maximum=20,
|
171 |
step=1
|
172 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
strength = gr.Slider(
|
174 |
label="Intensidad del sue帽o (Fuerza de transformaci贸n)",
|
175 |
value=0.7,
|
|
|
178 |
step=0.001
|
179 |
)
|
180 |
|
181 |
+
# Mover el componente de ejemplos aqu铆, justo debajo de Opciones Avanzadas
|
182 |
gr.Examples(examples=examples, inputs=text_prompt)
|
183 |
|
184 |
with gr.Row(elem_id="button-container"):
|
185 |
generate_button = gr.Button("QUIERO VER MI SUE脩O", elem_id="generate-button", variant="primary")
|
|
|
186 |
|
187 |
with gr.Column(scale=1):
|
188 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
189 |
|
190 |
+
generate_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, strength], outputs=image_output)
|
|
|
191 |
|
192 |
app.launch(show_api=False, share=False)
|