Update app.py
Browse files
app.py
CHANGED
@@ -15,14 +15,10 @@ import re
|
|
15 |
from gradio_client import Client
|
16 |
from fake_useragent import UserAgent
|
17 |
import random
|
18 |
-
from theme import theme
|
19 |
-
from fastapi import FastAPI
|
20 |
|
21 |
-
app = FastAPI()
|
22 |
-
@app.get("/")
|
23 |
|
24 |
-
def
|
25 |
-
result = {prompt:
|
26 |
print(result)
|
27 |
try:
|
28 |
language = detect(prompt)
|
@@ -179,39 +175,36 @@ def mirror(image_output, scale_by, method, gfpgan, codeformer):
|
|
179 |
img = Image.open(BytesIO(response2.content))
|
180 |
return img
|
181 |
|
182 |
-
examples = [
|
183 |
-
"a beautiful woman with blonde hair and blue eyes",
|
184 |
-
"a beautiful woman with brown hair and grey eyes",
|
185 |
-
"a beautiful woman with black hair and brown eyes",
|
186 |
-
]
|
187 |
-
|
188 |
-
# CSS to style the app
|
189 |
css = """
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
"""
|
196 |
|
197 |
-
with gr.Blocks(css=css
|
198 |
|
199 |
-
with gr.Tab("
|
200 |
with gr.Row():
|
201 |
-
prompt = gr.Textbox(placeholder="
|
202 |
with gr.Row():
|
203 |
-
task = gr.Radio(interactive=True, value="Stable Diffusion XL 1.0", show_label=True, label="
|
204 |
'Juggernaut XL', 'DreamShaper XL',
|
205 |
'SDXL Niji', 'Cinemax SDXL', 'NightVision XL',
|
206 |
'Playground v2', 'Artigen v3'])
|
207 |
-
|
208 |
-
examples = examples,
|
209 |
-
inputs = [prompt],
|
210 |
-
)
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
with gr.Tab("Extended settings"):
|
215 |
with gr.Row():
|
216 |
negative_prompt = gr.Textbox(placeholder="Negative Prompt", show_label=True, label='Negative Prompt:', lines=3, value="[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry")
|
217 |
with gr.Row():
|
@@ -224,31 +217,26 @@ with gr.Blocks(css=css, theme=theme, fill_width= False) as app:
|
|
224 |
with gr.Row():
|
225 |
seed = gr.Number(show_label=True, label="Seed:", minimum=-1, maximum=1000000, value=-1, step=1)
|
226 |
|
227 |
-
with gr.Tab("
|
228 |
with gr.Column():
|
229 |
with gr.Row():
|
230 |
-
scale_by = gr.Number(show_label=True, label="
|
231 |
with gr.Row():
|
232 |
-
method = gr.Dropdown(show_label=True, value="ESRGAN_4x", label="
|
233 |
with gr.Column():
|
234 |
with gr.Row():
|
235 |
-
gfpgan = gr.Slider(show_label=True, label="Эффект GFPGAN (
|
236 |
with gr.Row():
|
237 |
-
codeformer = gr.Slider(show_label=True, label="
|
238 |
|
239 |
with gr.Column():
|
240 |
-
text_button = gr.Button("
|
241 |
with gr.Column():
|
242 |
image_output = gr.Image(show_download_button=True, interactive=False, label='Результат:', elem_id='image_output', type='filepath')
|
243 |
-
text_button.click(
|
244 |
-
clear_prompt =gr.Button("Clear 🗑️",variant="primary", elem_id="clear_button")
|
245 |
-
clear_prompt.click(lambda: (None, None), None, [prompt, image_output], queue=False, show_api=False)
|
246 |
|
247 |
-
img2img_b = gr.Button("
|
248 |
-
image_i2i = gr.Image(show_label=True, label='
|
249 |
img2img_b.click(mirror, inputs=[image_output, scale_by, method, gfpgan, codeformer], outputs=image_i2i, concurrency_limit=48)
|
250 |
|
251 |
-
|
252 |
-
if __name__ == "__main__":
|
253 |
-
app.launch()
|
254 |
-
|
|
|
15 |
from gradio_client import Client
|
16 |
from fake_useragent import UserAgent
|
17 |
import random
|
|
|
|
|
18 |
|
|
|
|
|
19 |
|
20 |
+
def flip_text(prompt, negative_prompt, task, steps, sampler, cfg_scale, seed):
|
21 |
+
result = {"prompt": prompt,"negative_prompt": negative_prompt,"task": task,"steps": steps,"sampler": sampler,"cfg_scale": cfg_scale,"seed": seed}
|
22 |
print(result)
|
23 |
try:
|
24 |
language = detect(prompt)
|
|
|
175 |
img = Image.open(BytesIO(response2.content))
|
176 |
return img
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
css = """
|
179 |
+
#generate {
|
180 |
+
width: 100%;
|
181 |
+
background: #e253dd !important;
|
182 |
+
border: none;
|
183 |
+
border-radius: 50px;
|
184 |
+
outline: none !important;
|
185 |
+
color: white;
|
186 |
+
}
|
187 |
+
#generate:hover {
|
188 |
+
background: #de6bda !important;
|
189 |
+
outline: none !important;
|
190 |
+
color: #fff;
|
191 |
+
}
|
192 |
+
#image_output {
|
193 |
+
height: 100% !important;
|
194 |
}
|
195 |
"""
|
196 |
|
197 |
+
with gr.Blocks(css=css) as demo:
|
198 |
|
199 |
+
with gr.Tab("Базовые настройки"):
|
200 |
with gr.Row():
|
201 |
+
prompt = gr.Textbox(placeholder="Введите описание изображения...", show_label=True, label='Описание изображения:', lines=3)
|
202 |
with gr.Row():
|
203 |
+
task = gr.Radio(interactive=True, value="Stable Diffusion XL 1.0", show_label=True, label="Модель нейросети:", choices=['Stable Diffusion XL 1.0', 'Crystal Clear XL',
|
204 |
'Juggernaut XL', 'DreamShaper XL',
|
205 |
'SDXL Niji', 'Cinemax SDXL', 'NightVision XL',
|
206 |
'Playground v2', 'Artigen v3'])
|
207 |
+
with gr.Tab("Расширенные настройки"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
with gr.Row():
|
209 |
negative_prompt = gr.Textbox(placeholder="Negative Prompt", show_label=True, label='Negative Prompt:', lines=3, value="[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry")
|
210 |
with gr.Row():
|
|
|
217 |
with gr.Row():
|
218 |
seed = gr.Number(show_label=True, label="Seed:", minimum=-1, maximum=1000000, value=-1, step=1)
|
219 |
|
220 |
+
with gr.Tab("Настройки апскейлинга"):
|
221 |
with gr.Column():
|
222 |
with gr.Row():
|
223 |
+
scale_by = gr.Number(show_label=True, label="Во сколько раз увеличить:", minimum=1, maximum=2, value=2, step=1)
|
224 |
with gr.Row():
|
225 |
+
method = gr.Dropdown(show_label=True, value="ESRGAN_4x", label="Алгоритм увеличения", choices=["ScuNET GAN", "SwinIR 4x", "ESRGAN_4x", "R-ESRGAN 4x+", "R-ESRGAN 4x+ Anime6B"])
|
226 |
with gr.Column():
|
227 |
with gr.Row():
|
228 |
+
gfpgan = gr.Slider(show_label=True, label="Эффект GFPGAN (для улучшения лица)", minimum=0, maximum=1, value=0, step=0.1)
|
229 |
with gr.Row():
|
230 |
+
codeformer = gr.Slider(show_label=True, label="Эффект CodeFormer (для улучшения лица)", minimum=0, maximum=1, value=0, step=0.1)
|
231 |
|
232 |
with gr.Column():
|
233 |
+
text_button = gr.Button("Сгенерировать изображение", variant='primary', elem_id="generate")
|
234 |
with gr.Column():
|
235 |
image_output = gr.Image(show_download_button=True, interactive=False, label='Результат:', elem_id='image_output', type='filepath')
|
236 |
+
text_button.click(flip_text, inputs=[prompt, negative_prompt, task, steps, sampler, cfg_scale, seed], outputs=image_output, concurrency_limit=48)
|
|
|
|
|
237 |
|
238 |
+
img2img_b = gr.Button("Увеличить изображение", variant='secondary')
|
239 |
+
image_i2i = gr.Image(show_label=True, label='Увеличенное изображение:')
|
240 |
img2img_b.click(mirror, inputs=[image_output, scale_by, method, gfpgan, codeformer], outputs=image_i2i, concurrency_limit=48)
|
241 |
|
242 |
+
demo.launch()
|
|
|
|
|
|