Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -170,7 +170,7 @@ def process_example(prompt):
|
|
| 170 |
seed=get_random_seed()
|
| 171 |
)
|
| 172 |
|
| 173 |
-
# Gradio 인터페이스
|
| 174 |
with gr.Blocks(
|
| 175 |
theme=gr.themes.Soft(),
|
| 176 |
css="""
|
|
@@ -194,116 +194,130 @@ with gr.Blocks(
|
|
| 194 |
max-width: 1024px;
|
| 195 |
margin: auto;
|
| 196 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
"""
|
| 198 |
) as demo:
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
)
|
| 210 |
|
| 211 |
-
with gr.
|
| 212 |
-
with gr.
|
| 213 |
-
|
| 214 |
-
label="
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
| 217 |
)
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
maximum=1152,
|
| 225 |
-
step=64,
|
| 226 |
-
value=1024
|
| 227 |
-
)
|
| 228 |
-
width = gr.Slider(
|
| 229 |
-
label="Width",
|
| 230 |
-
minimum=256,
|
| 231 |
-
maximum=1152,
|
| 232 |
-
step=64,
|
| 233 |
-
value=1024
|
| 234 |
-
)
|
| 235 |
-
|
| 236 |
-
with gr.Row():
|
| 237 |
-
steps = gr.Slider(
|
| 238 |
-
label="Inference Steps",
|
| 239 |
-
minimum=6,
|
| 240 |
-
maximum=25,
|
| 241 |
-
step=1,
|
| 242 |
-
value=8
|
| 243 |
-
)
|
| 244 |
-
scales = gr.Slider(
|
| 245 |
-
label="Guidance Scale",
|
| 246 |
-
minimum=0.0,
|
| 247 |
-
maximum=5.0,
|
| 248 |
-
step=0.1,
|
| 249 |
-
value=3.5
|
| 250 |
-
)
|
| 251 |
-
|
| 252 |
-
seed = gr.Number(
|
| 253 |
-
label="Seed (random by default, set for reproducibility)",
|
| 254 |
-
value=get_random_seed(),
|
| 255 |
-
precision=0
|
| 256 |
-
)
|
| 257 |
-
|
| 258 |
-
randomize_seed = gr.Button("🎲 Randomize Seed", elem_classes=["generate-btn"])
|
| 259 |
-
|
| 260 |
-
generate_btn = gr.Button(
|
| 261 |
-
"✨ Generate Image",
|
| 262 |
-
elem_classes=["generate-btn"]
|
| 263 |
)
|
| 264 |
-
|
| 265 |
-
with gr.
|
| 266 |
-
|
| 267 |
-
label="
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
)
|
| 272 |
-
|
| 273 |
-
# 두 번째 탭 - Gallery
|
| 274 |
-
with gr.Tab("Gallery"):
|
| 275 |
-
with gr.Row():
|
| 276 |
-
gallery_html = "<div style='display: flex; flex-wrap: wrap; gap: 20px; padding: 20px;'>"
|
| 277 |
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
border-radius: 10px;
|
| 284 |
-
padding: 10px;
|
| 285 |
-
width: 300px;
|
| 286 |
-
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
| 287 |
-
'>
|
| 288 |
-
<img src='file/{img_file}'
|
| 289 |
-
style='width: 100%;
|
| 290 |
-
border-radius: 8px;
|
| 291 |
-
margin-bottom: 10px;'
|
| 292 |
-
>
|
| 293 |
-
<p style='
|
| 294 |
-
margin: 5px 0;
|
| 295 |
-
font-weight: bold;
|
| 296 |
-
color: #333;
|
| 297 |
-
'>Prompt: {prompt}</p>
|
| 298 |
-
</div>
|
| 299 |
-
"""
|
| 300 |
|
| 301 |
-
|
| 302 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
|
| 304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
def update_seed():
|
| 309 |
return get_random_seed()
|
|
|
|
| 170 |
seed=get_random_seed()
|
| 171 |
)
|
| 172 |
|
| 173 |
+
# Gradio 인터페이스 부분을 다음과 같이 수정
|
| 174 |
with gr.Blocks(
|
| 175 |
theme=gr.themes.Soft(),
|
| 176 |
css="""
|
|
|
|
| 194 |
max-width: 1024px;
|
| 195 |
margin: auto;
|
| 196 |
}
|
| 197 |
+
.gallery-container {
|
| 198 |
+
margin-top: 40px;
|
| 199 |
+
padding: 20px;
|
| 200 |
+
background: #f5f5f5;
|
| 201 |
+
border-radius: 15px;
|
| 202 |
+
}
|
| 203 |
+
.gallery-title {
|
| 204 |
+
text-align: center;
|
| 205 |
+
margin-bottom: 20px;
|
| 206 |
+
color: #333;
|
| 207 |
+
font-size: 1.5rem;
|
| 208 |
+
}
|
| 209 |
"""
|
| 210 |
) as demo:
|
| 211 |
+
gr.HTML(
|
| 212 |
+
"""
|
| 213 |
+
<div style="text-align: center; max-width: 800px; margin: 0 auto; padding: 20px;">
|
| 214 |
+
<h1 style="font-size: 2.5rem; color: #2196F3;">3D Style Image Generator</h1>
|
| 215 |
+
<p style="font-size: 1.2rem; color: #666;">Create amazing 3D-style images with AI</p>
|
| 216 |
+
</div>
|
| 217 |
+
"""
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
with gr.Row(elem_classes="container"):
|
| 221 |
+
with gr.Column(scale=3):
|
| 222 |
+
prompt = gr.Textbox(
|
| 223 |
+
label="Image Description",
|
| 224 |
+
placeholder="Describe the 3D image you want to create...",
|
| 225 |
+
lines=3
|
| 226 |
)
|
| 227 |
|
| 228 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 229 |
+
with gr.Row():
|
| 230 |
+
height = gr.Slider(
|
| 231 |
+
label="Height",
|
| 232 |
+
minimum=256,
|
| 233 |
+
maximum=1152,
|
| 234 |
+
step=64,
|
| 235 |
+
value=1024
|
| 236 |
)
|
| 237 |
+
width = gr.Slider(
|
| 238 |
+
label="Width",
|
| 239 |
+
minimum=256,
|
| 240 |
+
maximum=1152,
|
| 241 |
+
step=64,
|
| 242 |
+
value=1024
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
)
|
| 244 |
+
|
| 245 |
+
with gr.Row():
|
| 246 |
+
steps = gr.Slider(
|
| 247 |
+
label="Inference Steps",
|
| 248 |
+
minimum=6,
|
| 249 |
+
maximum=25,
|
| 250 |
+
step=1,
|
| 251 |
+
value=8
|
| 252 |
+
)
|
| 253 |
+
scales = gr.Slider(
|
| 254 |
+
label="Guidance Scale",
|
| 255 |
+
minimum=0.0,
|
| 256 |
+
maximum=5.0,
|
| 257 |
+
step=0.1,
|
| 258 |
+
value=3.5
|
| 259 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
+
seed = gr.Number(
|
| 262 |
+
label="Seed (random by default, set for reproducibility)",
|
| 263 |
+
value=get_random_seed(),
|
| 264 |
+
precision=0
|
| 265 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
|
| 267 |
+
randomize_seed = gr.Button("🎲 Randomize Seed", elem_classes=["generate-btn"])
|
| 268 |
+
|
| 269 |
+
generate_btn = gr.Button(
|
| 270 |
+
"✨ Generate Image",
|
| 271 |
+
elem_classes=["generate-btn"]
|
| 272 |
+
)
|
| 273 |
|
| 274 |
+
with gr.Column(scale=4, elem_classes=["fixed-width"]):
|
| 275 |
+
output = gr.Image(
|
| 276 |
+
label="Generated Image",
|
| 277 |
+
elem_id="output-image",
|
| 278 |
+
elem_classes=["output-image", "fixed-width"],
|
| 279 |
+
value="3d.webp"
|
| 280 |
+
)
|
| 281 |
|
| 282 |
+
# Gallery 섹션
|
| 283 |
+
with gr.Row(elem_classes="gallery-container"):
|
| 284 |
+
gr.HTML("<h2 class='gallery-title'>Gallery</h2>")
|
| 285 |
+
gallery_html = "<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>"
|
| 286 |
+
|
| 287 |
+
for img_file, prompt in SAMPLE_IMAGES.items():
|
| 288 |
+
if os.path.exists(img_file):
|
| 289 |
+
gallery_html += f"""
|
| 290 |
+
<div style='
|
| 291 |
+
border: 1px solid #ddd;
|
| 292 |
+
border-radius: 10px;
|
| 293 |
+
padding: 10px;
|
| 294 |
+
background: white;
|
| 295 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
| 296 |
+
'>
|
| 297 |
+
<img src='file/{img_file}'
|
| 298 |
+
style='width: 100%;
|
| 299 |
+
border-radius: 8px;
|
| 300 |
+
margin-bottom: 10px;'
|
| 301 |
+
>
|
| 302 |
+
<p style='
|
| 303 |
+
margin: 5px 0;
|
| 304 |
+
font-weight: bold;
|
| 305 |
+
color: #333;
|
| 306 |
+
padding: 10px;
|
| 307 |
+
'>Prompt: {prompt}</p>
|
| 308 |
+
</div>
|
| 309 |
+
"""
|
| 310 |
+
|
| 311 |
+
gallery_html += "</div>"
|
| 312 |
+
gr.HTML(gallery_html)
|
| 313 |
|
| 314 |
+
# Examples 섹션
|
| 315 |
+
with gr.Row():
|
| 316 |
+
gr.Examples(
|
| 317 |
+
label="Example Prompts",
|
| 318 |
+
examples=example_prompts,
|
| 319 |
+
inputs=prompt
|
| 320 |
+
)
|
| 321 |
|
| 322 |
def update_seed():
|
| 323 |
return get_random_seed()
|