Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import requests
|
|
3 |
import io
|
4 |
import random
|
5 |
import os
|
6 |
-
import time
|
7 |
from PIL import Image
|
8 |
from deep_translator import GoogleTranslator
|
9 |
|
@@ -14,7 +13,7 @@ API_TOKEN = os.getenv("HF_READ_TOKEN")
|
|
14 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
15 |
timeout = 100
|
16 |
|
17 |
-
def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras",
|
18 |
if not prompt:
|
19 |
return None
|
20 |
|
@@ -38,7 +37,6 @@ def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Ka
|
|
38 |
"is_negative": is_negative,
|
39 |
"steps": steps,
|
40 |
"cfg_scale": cfg_scale,
|
41 |
-
"seed": seed if seed != -1 else random.randint(1, 1000000000),
|
42 |
"strength": strength
|
43 |
}
|
44 |
|
@@ -75,7 +73,7 @@ input, textarea, select {
|
|
75 |
button {
|
76 |
background-color: #f5f5f5; /* Fondo gris claro */
|
77 |
color: #333333; /* Texto gris oscuro */
|
78 |
-
border:
|
79 |
}
|
80 |
|
81 |
button.primary {
|
@@ -116,25 +114,20 @@ with gr.Blocks(css=css) as app:
|
|
116 |
with gr.Row():
|
117 |
with gr.Column(scale=1):
|
118 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
with gr.Row(elem_id="button-row"):
|
127 |
-
clear_button = gr.Button("Clear", elem_id="clear-button", variant="secondary")
|
128 |
generate_button = gr.Button("Generate", elem_id="generate-button", variant="primary")
|
129 |
|
130 |
with gr.Column(scale=1):
|
131 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
132 |
|
133 |
-
generate_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method,
|
134 |
-
|
135 |
-
def clear_prompt():
|
136 |
-
return gr.Textbox.update(value="")
|
137 |
-
|
138 |
-
clear_button.click(clear_prompt, inputs=[], outputs=text_prompt)
|
139 |
|
140 |
app.launch(show_api=False, share=False)
|
|
|
3 |
import io
|
4 |
import random
|
5 |
import os
|
|
|
6 |
from PIL import Image
|
7 |
from deep_translator import GoogleTranslator
|
8 |
|
|
|
13 |
headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
14 |
timeout = 100
|
15 |
|
16 |
+
def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", strength=0.7):
|
17 |
if not prompt:
|
18 |
return None
|
19 |
|
|
|
37 |
"is_negative": is_negative,
|
38 |
"steps": steps,
|
39 |
"cfg_scale": cfg_scale,
|
|
|
40 |
"strength": strength
|
41 |
}
|
42 |
|
|
|
73 |
button {
|
74 |
background-color: #f5f5f5; /* Fondo gris claro */
|
75 |
color: #333333; /* Texto gris oscuro */
|
76 |
+
border: 1px solid black; /* Borde negro en botones */
|
77 |
}
|
78 |
|
79 |
button.primary {
|
|
|
114 |
with gr.Row():
|
115 |
with gr.Column(scale=1):
|
116 |
text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")
|
117 |
+
|
118 |
+
with gr.Accordion("Opciones Avanzadas", open=False):
|
119 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(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", lines=3, elem_id="negative-prompt-text-input")
|
120 |
+
steps = gr.Slider(label="Sampling steps", value=35, minimum=1, maximum=100, step=1)
|
121 |
+
cfg = gr.Slider(label="CFG Scale", value=7, minimum=1, maximum=20, step=1)
|
122 |
+
method = gr.Radio(label="Sampling method", value="DPM++ 2M Karras", choices=["DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM"])
|
123 |
+
strength = gr.Slider(label="Strength", value=0.7, minimum=0, maximum=1, step=0.001)
|
124 |
+
|
125 |
with gr.Row(elem_id="button-row"):
|
|
|
126 |
generate_button = gr.Button("Generate", elem_id="generate-button", variant="primary")
|
127 |
|
128 |
with gr.Column(scale=1):
|
129 |
image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")
|
130 |
|
131 |
+
generate_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, strength], outputs=image_output)
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
app.launch(show_api=False, share=False)
|