Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -81,39 +81,111 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
81 |
css = """
|
82 |
#col-container {
|
83 |
margin: 0 auto;
|
84 |
-
max-width:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
"""
|
87 |
|
88 |
with gr.Blocks(css=css) as demo:
|
89 |
with gr.Column(elem_id="col-container"):
|
90 |
gr.Markdown("""
|
91 |
-
|
92 |
-
|
93 |
""")
|
94 |
|
95 |
-
with gr.
|
96 |
-
prompt = gr.
|
97 |
-
label="
|
98 |
-
|
99 |
-
|
100 |
-
placeholder="
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
)
|
103 |
-
run_button = gr.Button("Run", scale=0)
|
104 |
|
105 |
result = gr.Image(
|
106 |
-
label="
|
107 |
-
show_label=
|
108 |
type="filepath",
|
109 |
elem_id="output_image"
|
110 |
)
|
111 |
|
112 |
-
with gr.Accordion("Advanced Settings", open=False):
|
113 |
-
negative_prompt = gr.
|
114 |
-
label="Negative
|
115 |
-
|
116 |
-
placeholder="
|
117 |
value="nsfw, (low quality, worst quality:1.2), very displeasing, 3d, watermark, signature, ugly, poorly drawn"
|
118 |
)
|
119 |
|
@@ -125,7 +197,11 @@ with gr.Blocks(css=css) as demo:
|
|
125 |
value=0,
|
126 |
)
|
127 |
|
128 |
-
randomize_seed = gr.Checkbox(
|
|
|
|
|
|
|
|
|
129 |
|
130 |
with gr.Row():
|
131 |
width = gr.Slider(
|
@@ -146,19 +222,21 @@ with gr.Blocks(css=css) as demo:
|
|
146 |
|
147 |
with gr.Row():
|
148 |
guidance_scale = gr.Slider(
|
149 |
-
label="Guidance
|
150 |
minimum=0.0,
|
151 |
maximum=20.0,
|
152 |
step=0.1,
|
153 |
value=7,
|
|
|
154 |
)
|
155 |
|
156 |
num_inference_steps = gr.Slider(
|
157 |
-
label="Number of
|
158 |
minimum=1,
|
159 |
maximum=28,
|
160 |
step=1,
|
161 |
value=28,
|
|
|
162 |
)
|
163 |
|
164 |
run_button.click(
|
|
|
81 |
css = """
|
82 |
#col-container {
|
83 |
margin: 0 auto;
|
84 |
+
max-width: 100%;
|
85 |
+
padding: 0 1rem;
|
86 |
+
}
|
87 |
+
|
88 |
+
/* プロンプト入力エリアのスタイル */
|
89 |
+
.prompt-input {
|
90 |
+
min-height: 100px !important;
|
91 |
+
font-size: 16px !important;
|
92 |
+
line-height: 1.5 !important;
|
93 |
+
padding: 12px !important;
|
94 |
+
border-radius: 8px !important;
|
95 |
+
border: 1px solid #e0e0e0 !important;
|
96 |
+
background-color: #ffffff !important;
|
97 |
+
}
|
98 |
+
|
99 |
+
.prompt-input:focus {
|
100 |
+
border-color: #2196f3 !important;
|
101 |
+
box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1) !important;
|
102 |
+
}
|
103 |
+
|
104 |
+
/* ボタンのスタイル */
|
105 |
+
.generate-button {
|
106 |
+
margin-top: 1rem !important;
|
107 |
+
padding: 12px 24px !important;
|
108 |
+
font-size: 16px !important;
|
109 |
+
font-weight: 600 !important;
|
110 |
+
border-radius: 8px !important;
|
111 |
+
background-color: #2196f3 !important;
|
112 |
+
color: white !important;
|
113 |
+
transition: all 0.3s ease !important;
|
114 |
+
}
|
115 |
+
|
116 |
+
.generate-button:hover {
|
117 |
+
background-color: #1976d2 !important;
|
118 |
+
transform: translateY(-1px) !important;
|
119 |
+
}
|
120 |
+
|
121 |
+
/* スマートフォン対応 */
|
122 |
+
@media (max-width: 768px) {
|
123 |
+
#col-container {
|
124 |
+
padding: 0 0.5rem;
|
125 |
+
}
|
126 |
+
|
127 |
+
.prompt-input {
|
128 |
+
font-size: 16px !important;
|
129 |
+
}
|
130 |
+
|
131 |
+
.advanced-settings {
|
132 |
+
margin-top: 1rem;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
/* 結果画像のコンテナ */
|
137 |
+
#output_image {
|
138 |
+
margin-top: 1rem;
|
139 |
+
border-radius: 8px;
|
140 |
+
overflow: hidden;
|
141 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
142 |
+
}
|
143 |
+
|
144 |
+
/* アコーディオンのスタイル */
|
145 |
+
.advanced-settings {
|
146 |
+
margin-top: 2rem;
|
147 |
+
border: 1px solid #e0e0e0;
|
148 |
+
border-radius: 8px;
|
149 |
+
overflow: hidden;
|
150 |
}
|
151 |
"""
|
152 |
|
153 |
with gr.Blocks(css=css) as demo:
|
154 |
with gr.Column(elem_id="col-container"):
|
155 |
gr.Markdown("""
|
156 |
+
# Text-to-Image Demo
|
157 |
+
Using [Noob SDXL beta model](https://huggingface.co/Laxhar) to generate amazing images!
|
158 |
""")
|
159 |
|
160 |
+
with gr.Group():
|
161 |
+
prompt = gr.Textbox(
|
162 |
+
label="What would you like to create?",
|
163 |
+
elem_classes="prompt-input",
|
164 |
+
lines=3,
|
165 |
+
placeholder="Describe the image you want to generate. Be specific about details, style, and atmosphere.\n\nExample: 'A serene mountain landscape at sunset, with snow-capped peaks and a clear lake reflection, painted in watercolor style'",
|
166 |
+
show_label=True,
|
167 |
+
)
|
168 |
+
|
169 |
+
run_button = gr.Button(
|
170 |
+
"✨ Generate Image",
|
171 |
+
elem_classes="generate-button",
|
172 |
+
variant="primary",
|
173 |
+
scale=1,
|
174 |
+
size="lg"
|
175 |
)
|
|
|
176 |
|
177 |
result = gr.Image(
|
178 |
+
label="Generated Image",
|
179 |
+
show_label=True,
|
180 |
type="filepath",
|
181 |
elem_id="output_image"
|
182 |
)
|
183 |
|
184 |
+
with gr.Accordion("Advanced Settings", open=False, elem_classes="advanced-settings"):
|
185 |
+
negative_prompt = gr.Textbox(
|
186 |
+
label="Negative Prompt",
|
187 |
+
lines=2,
|
188 |
+
placeholder="Specify what you don't want in the image. Example: nsfw, low quality, blur, etc.",
|
189 |
value="nsfw, (low quality, worst quality:1.2), very displeasing, 3d, watermark, signature, ugly, poorly drawn"
|
190 |
)
|
191 |
|
|
|
197 |
value=0,
|
198 |
)
|
199 |
|
200 |
+
randomize_seed = gr.Checkbox(
|
201 |
+
label="Randomize seed",
|
202 |
+
value=True,
|
203 |
+
info="Generate different results each time"
|
204 |
+
)
|
205 |
|
206 |
with gr.Row():
|
207 |
width = gr.Slider(
|
|
|
222 |
|
223 |
with gr.Row():
|
224 |
guidance_scale = gr.Slider(
|
225 |
+
label="Guidance Scale",
|
226 |
minimum=0.0,
|
227 |
maximum=20.0,
|
228 |
step=0.1,
|
229 |
value=7,
|
230 |
+
info="Controls how closely the image follows the prompt"
|
231 |
)
|
232 |
|
233 |
num_inference_steps = gr.Slider(
|
234 |
+
label="Number of Steps",
|
235 |
minimum=1,
|
236 |
maximum=28,
|
237 |
step=1,
|
238 |
value=28,
|
239 |
+
info="More steps = higher quality but slower generation"
|
240 |
)
|
241 |
|
242 |
run_button.click(
|