Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -17,8 +17,7 @@ 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",
|
@@ -27,13 +26,13 @@ examples = [
|
|
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(
|
@@ -49,15 +48,16 @@ def infer(
|
|
49 |
class CustomTheme(gr.themes.Base):
|
50 |
def __init__(self):
|
51 |
super().__init__()
|
52 |
-
self.primary_hue = "#
|
53 |
-
self.background_fill_primary = "#
|
54 |
-
self.background_fill_secondary = "#
|
55 |
-
self.background_fill_tertiary = "#
|
56 |
-
self.text_color_primary = "#
|
57 |
-
self.text_color_secondary = "#
|
58 |
-
self.text_color_tertiary = "#
|
59 |
-
self.input_background_fill = "#
|
60 |
-
self.input_text_color = "#
|
|
|
61 |
|
62 |
css = """
|
63 |
/* Скрываем нижний колонтитул */
|
@@ -68,30 +68,41 @@ footer {
|
|
68 |
padding: 0;
|
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;
|
88 |
}
|
|
|
89 |
input[type="range"]::-moz-range-thumb {
|
90 |
background: #5271FF;
|
91 |
}
|
|
|
92 |
input[type="range"]::-ms-thumb {
|
93 |
background: #5271FF;
|
94 |
}
|
|
|
95 |
input[type="checkbox"]:checked {
|
96 |
background-color: #5271FF;
|
97 |
}
|
@@ -99,13 +110,12 @@ input[type="checkbox"]:checked {
|
|
99 |
/* Выделяем текст для Prompt */
|
100 |
.prompt-text {
|
101 |
font-weight: bold;
|
|
|
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():
|
@@ -121,22 +131,20 @@ with gr.Blocks(theme=CustomTheme(), css=css) as demo:
|
|
121 |
"Generate",
|
122 |
scale=0,
|
123 |
variant="primary",
|
124 |
-
elem_classes="generate-button"
|
125 |
)
|
126 |
|
127 |
result = gr.Image(label="Result", show_label=False)
|
128 |
|
129 |
-
|
130 |
gr.Examples(
|
131 |
examples=examples,
|
132 |
inputs=[prompt],
|
133 |
outputs=[result],
|
134 |
fn=infer,
|
135 |
cache_examples=True,
|
136 |
-
cache_mode="lazy"
|
137 |
)
|
138 |
|
139 |
-
|
140 |
run_button.click(
|
141 |
fn=infer,
|
142 |
inputs=[prompt],
|
@@ -148,5 +156,5 @@ if __name__ == "__main__":
|
|
148 |
server_name="0.0.0.0",
|
149 |
server_port=7860,
|
150 |
share=True,
|
151 |
-
show_api=False
|
152 |
)
|
|
|
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 |
examples = [
|
23 |
"A border collie lying in some Fall leaves as the forest trees change colors",
|
|
|
26 |
]
|
27 |
|
28 |
|
29 |
+
@spaces.GPU(duration=30)
|
30 |
def infer(
|
31 |
prompt,
|
32 |
width=512,
|
33 |
height=512,
|
34 |
+
num_inference_steps=20,
|
35 |
+
guidance_scale=7.5,
|
36 |
):
|
37 |
# Генерация изображения
|
38 |
image = pipe(
|
|
|
48 |
class CustomTheme(gr.themes.Base):
|
49 |
def __init__(self):
|
50 |
super().__init__()
|
51 |
+
self.primary_hue = "#17181B"
|
52 |
+
self.background_fill_primary = "#17181B"
|
53 |
+
self.background_fill_secondary = "#17181B"
|
54 |
+
self.background_fill_tertiary = "#17181B"
|
55 |
+
self.text_color_primary = "#FFFFFF"
|
56 |
+
self.text_color_secondary = "#FFFFFF"
|
57 |
+
self.text_color_tertiary = "#FFFFFF"
|
58 |
+
self.input_background_fill = "#17181B"
|
59 |
+
self.input_text_color = "#FFFFFF"
|
60 |
+
|
61 |
|
62 |
css = """
|
63 |
/* Скрываем нижний колонтитул */
|
|
|
68 |
padding: 0;
|
69 |
overflow: hidden;
|
70 |
}
|
|
|
|
|
71 |
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap');
|
72 |
+
|
73 |
/* Применяем шрифты */
|
74 |
body, input, button, textarea, select, .gr-button {
|
75 |
font-family: 'Poppins', sans-serif;
|
76 |
+
background-color: #17181B !important;
|
77 |
+
color: #FFFFFF;
|
78 |
}
|
79 |
+
|
80 |
/* Настройки заголовков */
|
81 |
h1, h2, h3, h4, h5, h6 {
|
82 |
font-family: 'Poppins', sans-serif;
|
83 |
font-weight: 700;
|
84 |
+
color: #FFFFFF;
|
85 |
}
|
86 |
|
87 |
+
/* Стиль для текстовых полей и кнопок */
|
88 |
+
input[type="text"], textarea {
|
89 |
+
background-color: #17181B !important;
|
90 |
+
color: #FFFFFF;
|
91 |
+
border: 1px solid #FFFFFF;
|
92 |
+
}
|
93 |
|
|
|
94 |
input[type="range"]::-webkit-slider-thumb {
|
95 |
background: #5271FF;
|
96 |
}
|
97 |
+
|
98 |
input[type="range"]::-moz-range-thumb {
|
99 |
background: #5271FF;
|
100 |
}
|
101 |
+
|
102 |
input[type="range"]::-ms-thumb {
|
103 |
background: #5271FF;
|
104 |
}
|
105 |
+
|
106 |
input[type="checkbox"]:checked {
|
107 |
background-color: #5271FF;
|
108 |
}
|
|
|
110 |
/* Выделяем текст для Prompt */
|
111 |
.prompt-text {
|
112 |
font-weight: bold;
|
113 |
+
color: #FFFFFF;
|
114 |
}
|
115 |
"""
|
116 |
|
|
|
117 |
with gr.Blocks(theme=CustomTheme(), css=css) as demo:
|
118 |
with gr.Column(elem_id="col-container"):
|
|
|
119 |
gr.Markdown("**Prompt**", elem_classes="prompt-text")
|
120 |
|
121 |
with gr.Row():
|
|
|
131 |
"Generate",
|
132 |
scale=0,
|
133 |
variant="primary",
|
134 |
+
elem_classes="generate-button",
|
135 |
)
|
136 |
|
137 |
result = gr.Image(label="Result", show_label=False)
|
138 |
|
|
|
139 |
gr.Examples(
|
140 |
examples=examples,
|
141 |
inputs=[prompt],
|
142 |
outputs=[result],
|
143 |
fn=infer,
|
144 |
cache_examples=True,
|
145 |
+
cache_mode="lazy",
|
146 |
)
|
147 |
|
|
|
148 |
run_button.click(
|
149 |
fn=infer,
|
150 |
inputs=[prompt],
|
|
|
156 |
server_name="0.0.0.0",
|
157 |
server_port=7860,
|
158 |
share=True,
|
159 |
+
show_api=False,
|
160 |
)
|