Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -17,23 +17,23 @@ else:
|
|
17 |
pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
|
18 |
pipe = pipe.to(device)
|
19 |
|
20 |
-
MAX_IMAGE_SIZE = 512
|
|
|
21 |
|
22 |
-
# Примеры для интерфейса
|
23 |
examples = [
|
24 |
"A border collie lying in some Fall leaves as the forest trees change colors",
|
25 |
"A cyberpunk cityscape with neon lights and flying cars at night",
|
26 |
"A fantasy castle surrounded by mountains under a pink and purple sunset",
|
27 |
]
|
28 |
|
29 |
-
|
30 |
-
@spaces.GPU(duration=30)
|
31 |
def infer(
|
32 |
prompt,
|
33 |
width=512,
|
34 |
height=512,
|
35 |
-
num_inference_steps=20,
|
36 |
-
guidance_scale=7.5,
|
37 |
):
|
38 |
# Генерация изображения
|
39 |
image = pipe(
|
@@ -45,21 +45,20 @@ def infer(
|
|
45 |
).images[0]
|
46 |
return image
|
47 |
|
48 |
-
|
49 |
class CustomTheme(gr.themes.Base):
|
50 |
def __init__(self):
|
51 |
super().__init__()
|
52 |
self.primary_hue = "#5271FF"
|
53 |
-
self.background_fill_primary = "#
|
54 |
-
self.background_fill_secondary = "#
|
55 |
-
self.background_fill_tertiary = "#
|
56 |
self.text_color_primary = "#AEB3B8"
|
57 |
self.text_color_secondary = "#AEB3B8"
|
58 |
self.text_color_tertiary = "#AEB3B8"
|
59 |
-
self.input_background_fill = "#AEB3B8"
|
60 |
-
self.input_text_color = "#AEB3B8"
|
61 |
|
62 |
-
# CSS для интерфейса
|
63 |
css = """
|
64 |
/* Скрываем нижний колонтитул */
|
65 |
footer {
|
@@ -70,20 +69,19 @@ footer {
|
|
70 |
overflow: hidden;
|
71 |
}
|
72 |
|
73 |
-
/* Импортируем шрифты */
|
74 |
-
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Montserrat:wght@500;700&display=swap');
|
75 |
|
|
|
76 |
/* Применяем шрифты */
|
77 |
body, input, button, textarea, select, .gr-button {
|
78 |
-
font-family: '
|
79 |
}
|
80 |
-
|
81 |
/* Настройки заголовков */
|
82 |
h1, h2, h3, h4, h5, h6 {
|
83 |
-
font-family: '
|
84 |
font-weight: 700;
|
85 |
}
|
86 |
|
|
|
87 |
/* Дополнительный стиль для слайдеров и чекбоксов */
|
88 |
input[type="range"]::-webkit-slider-thumb {
|
89 |
background: #5271FF;
|
@@ -104,10 +102,10 @@ input[type="checkbox"]:checked {
|
|
104 |
}
|
105 |
"""
|
106 |
|
107 |
-
|
108 |
with gr.Blocks(theme=CustomTheme(), css=css) as demo:
|
109 |
with gr.Column(elem_id="col-container"):
|
110 |
-
|
111 |
gr.Markdown("**Prompt**", elem_classes="prompt-text")
|
112 |
|
113 |
with gr.Row():
|
@@ -128,7 +126,7 @@ with gr.Blocks(theme=CustomTheme(), css=css) as demo:
|
|
128 |
|
129 |
result = gr.Image(label="Result", show_label=False)
|
130 |
|
131 |
-
|
132 |
gr.Examples(
|
133 |
examples=examples,
|
134 |
inputs=[prompt],
|
@@ -138,7 +136,7 @@ with gr.Blocks(theme=CustomTheme(), css=css) as demo:
|
|
138 |
cache_mode="lazy"
|
139 |
)
|
140 |
|
141 |
-
|
142 |
run_button.click(
|
143 |
fn=infer,
|
144 |
inputs=[prompt],
|
|
|
17 |
pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
|
18 |
pipe = pipe.to(device)
|
19 |
|
20 |
+
MAX_IMAGE_SIZE = 512
|
21 |
+
|
22 |
|
|
|
23 |
examples = [
|
24 |
"A border collie lying in some Fall leaves as the forest trees change colors",
|
25 |
"A cyberpunk cityscape with neon lights and flying cars at night",
|
26 |
"A fantasy castle surrounded by mountains under a pink and purple sunset",
|
27 |
]
|
28 |
|
29 |
+
|
30 |
+
@spaces.GPU(duration=30)
|
31 |
def infer(
|
32 |
prompt,
|
33 |
width=512,
|
34 |
height=512,
|
35 |
+
num_inference_steps=20,
|
36 |
+
guidance_scale=7.5,
|
37 |
):
|
38 |
# Генерация изображения
|
39 |
image = pipe(
|
|
|
45 |
).images[0]
|
46 |
return image
|
47 |
|
48 |
+
|
49 |
class CustomTheme(gr.themes.Base):
|
50 |
def __init__(self):
|
51 |
super().__init__()
|
52 |
self.primary_hue = "#5271FF"
|
53 |
+
self.background_fill_primary = "#AEB3B8"
|
54 |
+
self.background_fill_secondary = "#AEB3B8"
|
55 |
+
self.background_fill_tertiary = "#AEB3B8"
|
56 |
self.text_color_primary = "#AEB3B8"
|
57 |
self.text_color_secondary = "#AEB3B8"
|
58 |
self.text_color_tertiary = "#AEB3B8"
|
59 |
+
self.input_background_fill = "#AEB3B8"
|
60 |
+
self.input_text_color = "#AEB3B8"
|
61 |
|
|
|
62 |
css = """
|
63 |
/* Скрываем нижний колонтитул */
|
64 |
footer {
|
|
|
69 |
overflow: hidden;
|
70 |
}
|
71 |
|
|
|
|
|
72 |
|
73 |
+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap');
|
74 |
/* Применяем шрифты */
|
75 |
body, input, button, textarea, select, .gr-button {
|
76 |
+
font-family: 'Poppins', sans-serif;
|
77 |
}
|
|
|
78 |
/* Настройки заголовков */
|
79 |
h1, h2, h3, h4, h5, h6 {
|
80 |
+
font-family: 'Poppins', sans-serif;
|
81 |
font-weight: 700;
|
82 |
}
|
83 |
|
84 |
+
|
85 |
/* Дополнительный стиль для слайдеров и чекбоксов */
|
86 |
input[type="range"]::-webkit-slider-thumb {
|
87 |
background: #5271FF;
|
|
|
102 |
}
|
103 |
"""
|
104 |
|
105 |
+
|
106 |
with gr.Blocks(theme=CustomTheme(), css=css) as demo:
|
107 |
with gr.Column(elem_id="col-container"):
|
108 |
+
|
109 |
gr.Markdown("**Prompt**", elem_classes="prompt-text")
|
110 |
|
111 |
with gr.Row():
|
|
|
126 |
|
127 |
result = gr.Image(label="Result", show_label=False)
|
128 |
|
129 |
+
|
130 |
gr.Examples(
|
131 |
examples=examples,
|
132 |
inputs=[prompt],
|
|
|
136 |
cache_mode="lazy"
|
137 |
)
|
138 |
|
139 |
+
|
140 |
run_button.click(
|
141 |
fn=infer,
|
142 |
inputs=[prompt],
|