Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -207,121 +207,116 @@ def generate_images(prompt, num_steps, seed, height, width, style_preset,
|
|
| 207 |
|
| 208 |
yield gallery_val, final_status, json.dumps(summary, indent=2)
|
| 209 |
|
| 210 |
-
# Custom CSS
|
| 211 |
custom_css = """
|
| 212 |
-
:root {
|
| 213 |
-
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 214 |
-
--primary-color: #4f46e5;
|
| 215 |
-
--success-color: #10b981;
|
| 216 |
-
--error-color: #ef4444;
|
| 217 |
-
--warning-color: #f59e0b;
|
| 218 |
-
}
|
| 219 |
-
|
| 220 |
.gradio-container {
|
| 221 |
max-width: 1200px !important;
|
| 222 |
margin: 0 auto !important;
|
| 223 |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
| 224 |
}
|
| 225 |
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
| 234 |
}
|
| 235 |
|
| 236 |
.header-title {
|
| 237 |
-
font-size: 2.8em;
|
| 238 |
-
font-weight: 700;
|
| 239 |
-
margin-bottom: 10px;
|
| 240 |
-
display: flex;
|
| 241 |
-
align-items: center;
|
| 242 |
-
justify-content: center;
|
| 243 |
-
gap: 15px;
|
| 244 |
}
|
| 245 |
|
| 246 |
.header-subtitle {
|
| 247 |
-
font-size: 1.2em;
|
| 248 |
-
opacity: 0.9;
|
| 249 |
-
max-width: 600px;
|
| 250 |
-
margin: 0 auto;
|
| 251 |
}
|
| 252 |
|
|
|
|
| 253 |
.api-status {
|
| 254 |
-
padding: 16px 20px;
|
| 255 |
-
border-radius: 12px;
|
| 256 |
-
margin-bottom: 25px;
|
| 257 |
-
font-weight: 600;
|
| 258 |
-
font-size: 1.1em;
|
| 259 |
-
border-left: 6px solid;
|
| 260 |
}
|
| 261 |
|
| 262 |
.api-status-success {
|
| 263 |
-
background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
|
| 264 |
-
color: #065f46;
|
| 265 |
-
border-left-color:
|
| 266 |
}
|
| 267 |
|
| 268 |
.api-status-error {
|
| 269 |
-
background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
|
| 270 |
-
color: #7f1d1d;
|
| 271 |
-
border-left-color:
|
| 272 |
}
|
| 273 |
|
|
|
|
| 274 |
.input-section {
|
| 275 |
-
background: white;
|
| 276 |
-
padding: 30px;
|
| 277 |
-
border-radius: 16px;
|
| 278 |
-
border: 1px solid #e5e7eb;
|
| 279 |
-
box-shadow: 0 4px 20px rgba(0,0,0,0.05);
|
| 280 |
-
margin-bottom: 25px;
|
| 281 |
}
|
| 282 |
|
| 283 |
.section-title {
|
| 284 |
-
color: #333;
|
| 285 |
-
font-size: 1.4em;
|
| 286 |
-
font-weight: 600;
|
| 287 |
-
margin-bottom: 20px;
|
| 288 |
-
display: flex;
|
| 289 |
-
align-items: center;
|
| 290 |
-
gap: 10px;
|
| 291 |
}
|
| 292 |
|
|
|
|
| 293 |
.example-card {
|
| 294 |
-
background: #f8fafc;
|
| 295 |
-
padding: 20px;
|
| 296 |
-
border-radius: 12px;
|
| 297 |
-
border: 2px solid #e2e8f0;
|
| 298 |
-
margin: 12px 0;
|
| 299 |
-
cursor: pointer;
|
| 300 |
-
transition: all 0.3s
|
|
|
|
|
|
|
| 301 |
}
|
| 302 |
|
| 303 |
.example-card:hover {
|
| 304 |
-
background: #e2e8f0;
|
| 305 |
-
transform: translateY(-4px);
|
| 306 |
-
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
|
| 307 |
-
border-color:
|
| 308 |
}
|
| 309 |
|
| 310 |
.example-title {
|
| 311 |
-
color:
|
| 312 |
-
font-weight: 600;
|
| 313 |
-
font-size: 1.1em;
|
| 314 |
-
margin-bottom: 8px;
|
| 315 |
}
|
| 316 |
|
| 317 |
.example-desc {
|
| 318 |
-
color: #666;
|
| 319 |
-
font-size: 0.95em;
|
| 320 |
-
line-height: 1.4;
|
| 321 |
}
|
| 322 |
|
|
|
|
| 323 |
.generate-btn {
|
| 324 |
-
background:
|
| 325 |
color: white !important;
|
| 326 |
font-weight: 700 !important;
|
| 327 |
padding: 18px 40px !important;
|
|
@@ -329,12 +324,12 @@ custom_css = """
|
|
| 329 |
border-radius: 12px !important;
|
| 330 |
border: none !important;
|
| 331 |
transition: all 0.3s ease !important;
|
| 332 |
-
box-shadow: 0 8px 25px rgba(
|
| 333 |
}
|
| 334 |
|
| 335 |
.generate-btn:hover {
|
| 336 |
transform: translateY(-3px) !important;
|
| 337 |
-
box-shadow: 0 15px 35px rgba(
|
| 338 |
}
|
| 339 |
|
| 340 |
.secondary-btn {
|
|
@@ -343,52 +338,58 @@ custom_css = """
|
|
| 343 |
border: 2px solid #e2e8f0 !important;
|
| 344 |
}
|
| 345 |
|
| 346 |
-
|
| 347 |
-
background: #f9fafb;
|
| 348 |
-
padding: 20px;
|
| 349 |
-
border-radius: 12px;
|
| 350 |
-
margin-bottom: 20px;
|
| 351 |
-
border: 1px solid #e5e7eb;
|
| 352 |
-
}
|
| 353 |
-
|
| 354 |
.gallery-container {
|
| 355 |
-
background: white;
|
| 356 |
-
padding: 25px;
|
| 357 |
-
border-radius: 16px;
|
| 358 |
-
border: 1px solid #e5e7eb;
|
| 359 |
-
box-shadow: 0 4px 20px rgba(0,0,0,0.05);
|
| 360 |
}
|
| 361 |
|
|
|
|
| 362 |
.status-box {
|
| 363 |
-
background: #f8fafc;
|
| 364 |
-
padding: 20px;
|
| 365 |
-
border-radius: 12px;
|
| 366 |
-
border-left: 5px solid
|
| 367 |
-
margin-bottom: 20px;
|
| 368 |
-
font-size: 1.1em;
|
| 369 |
}
|
| 370 |
|
|
|
|
| 371 |
.footer {
|
| 372 |
-
text-align: center;
|
| 373 |
-
color: #666;
|
| 374 |
-
font-size: 0.9em;
|
| 375 |
-
margin-top: 40px;
|
| 376 |
-
padding-top: 20px;
|
| 377 |
-
border-top: 1px solid #e5e7eb;
|
| 378 |
}
|
| 379 |
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
}
|
| 384 |
"""
|
| 385 |
|
| 386 |
-
# Create the
|
| 387 |
-
with gr.Blocks(title="Pixazo Image Generator") as demo:
|
| 388 |
|
| 389 |
-
#
|
| 390 |
gr.HTML("""
|
| 391 |
-
<div class="header-
|
| 392 |
<div class="header-title">
|
| 393 |
🎨 Pixazo Image Generator
|
| 394 |
</div>
|
|
@@ -414,99 +415,82 @@ with gr.Blocks(title="Pixazo Image Generator") as demo:
|
|
| 414 |
</div>
|
| 415 |
""")
|
| 416 |
|
| 417 |
-
with gr.Row(
|
| 418 |
# Left Column - Inputs
|
| 419 |
-
with gr.Column(scale=1
|
| 420 |
# Prompt Section
|
| 421 |
with gr.Group(elem_classes="input-section"):
|
| 422 |
-
gr.Markdown(""
|
| 423 |
-
<div class="section-title">
|
| 424 |
-
✨ Image Description
|
| 425 |
-
</div>
|
| 426 |
-
""")
|
| 427 |
prompt = gr.Textbox(
|
| 428 |
label="",
|
| 429 |
-
placeholder="Describe the image you want to generate
|
| 430 |
lines=4,
|
| 431 |
-
show_label=False
|
| 432 |
-
container=False
|
| 433 |
)
|
| 434 |
|
| 435 |
# Parameters Section
|
| 436 |
with gr.Group(elem_classes="input-section"):
|
| 437 |
-
gr.Markdown(""
|
| 438 |
-
<div class="section-title">
|
| 439 |
-
⚙️ Generation Parameters
|
| 440 |
-
</div>
|
| 441 |
-
""")
|
| 442 |
|
| 443 |
with gr.Row():
|
| 444 |
style_preset = gr.Dropdown(
|
| 445 |
-
label="
|
| 446 |
choices=[
|
| 447 |
"none", "cyberpunk", "fantasy", "anime", "photographic",
|
| 448 |
"digital-art", "comic", "3d-model", "pixel-art",
|
| 449 |
-
"isometric", "watercolor", "oil-painting", "sketch"
|
| 450 |
-
"cinematic", "sci-fi", "renaissance", "impressionist"
|
| 451 |
],
|
| 452 |
-
value="none"
|
| 453 |
-
info="Select an art style"
|
| 454 |
)
|
| 455 |
|
| 456 |
with gr.Row():
|
| 457 |
guidance_scale = gr.Slider(
|
| 458 |
-
label="
|
| 459 |
minimum=1.0,
|
| 460 |
maximum=20.0,
|
| 461 |
value=7.5,
|
| 462 |
-
step=0.5
|
| 463 |
-
info="Higher values = more prompt adherence"
|
| 464 |
)
|
| 465 |
|
| 466 |
with gr.Row():
|
| 467 |
num_steps = gr.Slider(
|
| 468 |
-
label="
|
| 469 |
minimum=1,
|
| 470 |
-
maximum=
|
| 471 |
value=4,
|
| 472 |
-
step=1
|
| 473 |
-
info="More steps = better quality but slower"
|
| 474 |
)
|
| 475 |
|
| 476 |
seed = gr.Number(
|
| 477 |
-
label="
|
| 478 |
value=42,
|
| 479 |
minimum=0,
|
| 480 |
-
maximum=999999
|
| 481 |
-
info="0 for random, fixed for reproducible results"
|
| 482 |
)
|
| 483 |
|
| 484 |
with gr.Row():
|
| 485 |
width = gr.Slider(
|
| 486 |
-
label="
|
| 487 |
minimum=256,
|
| 488 |
-
maximum=
|
| 489 |
value=512,
|
| 490 |
-
step=64
|
| 491 |
-
info="Image width in pixels"
|
| 492 |
)
|
| 493 |
|
| 494 |
height = gr.Slider(
|
| 495 |
-
label="
|
| 496 |
minimum=256,
|
| 497 |
-
maximum=
|
| 498 |
value=512,
|
| 499 |
-
step=64
|
| 500 |
-
info="Image height in pixels"
|
| 501 |
)
|
| 502 |
|
| 503 |
num_images = gr.Slider(
|
| 504 |
-
label="
|
| 505 |
minimum=1,
|
| 506 |
maximum=8,
|
| 507 |
value=1,
|
| 508 |
-
step=1
|
| 509 |
-
info="Generate multiple variations"
|
| 510 |
)
|
| 511 |
|
| 512 |
# Action Buttons
|
|
@@ -514,65 +498,47 @@ with gr.Blocks(title="Pixazo Image Generator") as demo:
|
|
| 514 |
generate_btn = gr.Button(
|
| 515 |
"✨ Generate Images",
|
| 516 |
variant="primary",
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
)
|
| 520 |
-
clear_btn = gr.Button(
|
| 521 |
-
"🗑️ Clear",
|
| 522 |
-
variant="secondary",
|
| 523 |
-
scale=1,
|
| 524 |
-
elem_classes="secondary-btn"
|
| 525 |
)
|
|
|
|
| 526 |
|
| 527 |
# Examples Section
|
| 528 |
with gr.Group(elem_classes="input-section"):
|
| 529 |
-
gr.Markdown(""
|
| 530 |
-
<div class="section-title">
|
| 531 |
-
💡 Example Prompts
|
| 532 |
-
</div>
|
| 533 |
-
<p style="color: #666; margin-bottom: 15px;">Click any example to try it:</p>
|
| 534 |
-
""")
|
| 535 |
|
| 536 |
examples = [
|
| 537 |
-
("Cyberpunk
|
| 538 |
-
("Fantasy Dragon", "A majestic dragon
|
| 539 |
-
("Anime Character", "A cute anime girl with magical powers in a cherry blossom garden
|
| 540 |
-
("Space Explorer", "An astronaut on Mars with detailed reflection in visor
|
| 541 |
-
("Isometric
|
| 542 |
]
|
| 543 |
|
| 544 |
for title, desc, style in examples:
|
| 545 |
-
# Create
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
size="sm",
|
| 549 |
variant="secondary",
|
|
|
|
| 550 |
elem_classes="example-card"
|
| 551 |
)
|
| 552 |
|
| 553 |
def use_example(p=desc, s=style):
|
| 554 |
return p, s
|
| 555 |
|
| 556 |
-
|
| 557 |
use_example,
|
| 558 |
outputs=[prompt, style_preset]
|
| 559 |
)
|
| 560 |
|
| 561 |
# Right Column - Outputs
|
| 562 |
-
with gr.Column(scale=2
|
| 563 |
# Status Display
|
| 564 |
-
gr.HTML("""
|
| 565 |
-
<div class="section-title">
|
| 566 |
-
📊 Generation Results
|
| 567 |
-
</div>
|
| 568 |
-
""")
|
| 569 |
-
|
| 570 |
status = gr.Textbox(
|
| 571 |
-
label="",
|
| 572 |
-
value="🎯 Ready to generate images. Enter a prompt above
|
| 573 |
interactive=False,
|
| 574 |
-
lines=2,
|
| 575 |
-
container=False,
|
| 576 |
elem_classes="status-box"
|
| 577 |
)
|
| 578 |
|
|
@@ -582,55 +548,37 @@ with gr.Blocks(title="Pixazo Image Generator") as demo:
|
|
| 582 |
label="🎨 Generated Images",
|
| 583 |
columns=3,
|
| 584 |
height="auto",
|
| 585 |
-
|
| 586 |
-
show_label=True,
|
| 587 |
-
preview=True
|
| 588 |
)
|
| 589 |
|
| 590 |
-
# Tabs
|
| 591 |
with gr.Tabs():
|
| 592 |
-
with gr.TabItem("
|
| 593 |
json_output = gr.JSON(
|
| 594 |
-
label="API Response
|
| 595 |
container=True
|
| 596 |
)
|
| 597 |
|
| 598 |
-
with gr.TabItem("🛠️ Quick Actions"):
|
| 599 |
-
with gr.Column():
|
| 600 |
-
gr.Markdown("""
|
| 601 |
-
### Quick Actions
|
| 602 |
-
|
| 603 |
-
**Download Options:**
|
| 604 |
-
- Right-click any image to save it
|
| 605 |
-
- Use browser's "Save image as" option
|
| 606 |
-
|
| 607 |
-
**Tips for Better Results:**
|
| 608 |
-
1. **Be descriptive** - Include details about lighting, style, mood
|
| 609 |
-
2. **Use specific styles** - Try different style presets
|
| 610 |
-
3. **Adjust guidance** - Higher values follow prompt more closely
|
| 611 |
-
4. **Experiment with seeds** - Same seed + same prompt = same image
|
| 612 |
-
""")
|
| 613 |
-
|
| 614 |
with gr.TabItem("ℹ️ About"):
|
| 615 |
gr.Markdown(f"""
|
| 616 |
-
### About This
|
| 617 |
|
| 618 |
**Version:** 1.0.0
|
| 619 |
**Gradio:** {gr.__version__}
|
| 620 |
**API Format:** `{"output": "IMAGE_URL"}`
|
| 621 |
|
| 622 |
-
**
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
|
|
|
|
|
|
| 627 |
|
| 628 |
**Credits:**
|
| 629 |
-
- Powered by
|
| 630 |
-
- Built with
|
| 631 |
-
- Hosted on
|
| 632 |
-
|
| 633 |
-
**Note:** API key must be set in Space secrets for this to work.
|
| 634 |
""")
|
| 635 |
|
| 636 |
# Footer
|
|
@@ -647,14 +595,13 @@ with gr.Blocks(title="Pixazo Image Generator") as demo:
|
|
| 647 |
yield None, "❌ Please enter a prompt first", {"error": "No prompt provided"}
|
| 648 |
return
|
| 649 |
|
| 650 |
-
# Generator function that yields progress
|
| 651 |
for gallery_val, status_val, json_val in generate_images(
|
| 652 |
prompt, num_steps, seed, height, width, style_preset, num_images, guidance_scale
|
| 653 |
):
|
| 654 |
yield gallery_val, status_val, json_val
|
| 655 |
|
| 656 |
def on_clear():
|
| 657 |
-
return None, "🎯 Ready to generate images. Enter a prompt above
|
| 658 |
|
| 659 |
# Connect buttons
|
| 660 |
generate_btn.click(
|
|
@@ -668,16 +615,15 @@ with gr.Blocks(title="Pixazo Image Generator") as demo:
|
|
| 668 |
outputs=[gallery, status, json_output]
|
| 669 |
)
|
| 670 |
|
| 671 |
-
# Launch
|
| 672 |
if __name__ == "__main__":
|
| 673 |
print("=" * 60)
|
| 674 |
-
print("🚀 Pixazo Image Generator")
|
| 675 |
-
print("🎨 Beautiful UI
|
| 676 |
print(f"📦 Gradio Version: {gr.__version__}")
|
| 677 |
-
print(f"🔑 API Key
|
| 678 |
print("=" * 60)
|
| 679 |
|
| 680 |
-
# Launch with css parameter in launch() method for Gradio 6.x
|
| 681 |
demo.launch(
|
| 682 |
server_name="0.0.0.0",
|
| 683 |
server_port=7860,
|
|
|
|
| 207 |
|
| 208 |
yield gallery_val, final_status, json.dumps(summary, indent=2)
|
| 209 |
|
| 210 |
+
# Custom CSS - Keep the beauty alive! 🎨
|
| 211 |
custom_css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
.gradio-container {
|
| 213 |
max-width: 1200px !important;
|
| 214 |
margin: 0 auto !important;
|
| 215 |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
| 216 |
}
|
| 217 |
|
| 218 |
+
/* Beautiful Gradient Header */
|
| 219 |
+
.header-gradient {
|
| 220 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
| 221 |
+
color: white !important;
|
| 222 |
+
padding: 40px 30px !important;
|
| 223 |
+
border-radius: 16px !important;
|
| 224 |
+
margin-bottom: 30px !important;
|
| 225 |
+
text-align: center !important;
|
| 226 |
+
box-shadow: 0 20px 60px rgba(102, 126, 234, 0.3) !important;
|
| 227 |
}
|
| 228 |
|
| 229 |
.header-title {
|
| 230 |
+
font-size: 2.8em !important;
|
| 231 |
+
font-weight: 700 !important;
|
| 232 |
+
margin-bottom: 10px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
}
|
| 234 |
|
| 235 |
.header-subtitle {
|
| 236 |
+
font-size: 1.2em !important;
|
| 237 |
+
opacity: 0.9 !important;
|
| 238 |
+
max-width: 600px !important;
|
| 239 |
+
margin: 0 auto !important;
|
| 240 |
}
|
| 241 |
|
| 242 |
+
/* API Status */
|
| 243 |
.api-status {
|
| 244 |
+
padding: 16px 20px !important;
|
| 245 |
+
border-radius: 12px !important;
|
| 246 |
+
margin-bottom: 25px !important;
|
| 247 |
+
font-weight: 600 !important;
|
| 248 |
+
font-size: 1.1em !important;
|
| 249 |
+
border-left: 6px solid !important;
|
| 250 |
}
|
| 251 |
|
| 252 |
.api-status-success {
|
| 253 |
+
background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%) !important;
|
| 254 |
+
color: #065f46 !important;
|
| 255 |
+
border-left-color: #10b981 !important;
|
| 256 |
}
|
| 257 |
|
| 258 |
.api-status-error {
|
| 259 |
+
background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%) !important;
|
| 260 |
+
color: #7f1d1d !important;
|
| 261 |
+
border-left-color: #ef4444 !important;
|
| 262 |
}
|
| 263 |
|
| 264 |
+
/* Input Sections */
|
| 265 |
.input-section {
|
| 266 |
+
background: white !important;
|
| 267 |
+
padding: 30px !important;
|
| 268 |
+
border-radius: 16px !important;
|
| 269 |
+
border: 1px solid #e5e7eb !important;
|
| 270 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.05) !important;
|
| 271 |
+
margin-bottom: 25px !important;
|
| 272 |
}
|
| 273 |
|
| 274 |
.section-title {
|
| 275 |
+
color: #333 !important;
|
| 276 |
+
font-size: 1.4em !important;
|
| 277 |
+
font-weight: 600 !important;
|
| 278 |
+
margin-bottom: 20px !important;
|
| 279 |
+
display: flex !important;
|
| 280 |
+
align-items: center !important;
|
| 281 |
+
gap: 10px !important;
|
| 282 |
}
|
| 283 |
|
| 284 |
+
/* Example Cards */
|
| 285 |
.example-card {
|
| 286 |
+
background: #f8fafc !important;
|
| 287 |
+
padding: 20px !important;
|
| 288 |
+
border-radius: 12px !important;
|
| 289 |
+
border: 2px solid #e2e8f0 !important;
|
| 290 |
+
margin: 12px 0 !important;
|
| 291 |
+
cursor: pointer !important;
|
| 292 |
+
transition: all 0.3s ease !important;
|
| 293 |
+
text-align: left !important;
|
| 294 |
+
width: 100% !important;
|
| 295 |
}
|
| 296 |
|
| 297 |
.example-card:hover {
|
| 298 |
+
background: #e2e8f0 !important;
|
| 299 |
+
transform: translateY(-4px) !important;
|
| 300 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.1) !important;
|
| 301 |
+
border-color: #4f46e5 !important;
|
| 302 |
}
|
| 303 |
|
| 304 |
.example-title {
|
| 305 |
+
color: #4f46e5 !important;
|
| 306 |
+
font-weight: 600 !important;
|
| 307 |
+
font-size: 1.1em !important;
|
| 308 |
+
margin-bottom: 8px !important;
|
| 309 |
}
|
| 310 |
|
| 311 |
.example-desc {
|
| 312 |
+
color: #666 !important;
|
| 313 |
+
font-size: 0.95em !important;
|
| 314 |
+
line-height: 1.4 !important;
|
| 315 |
}
|
| 316 |
|
| 317 |
+
/* Beautiful Generate Button */
|
| 318 |
.generate-btn {
|
| 319 |
+
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
|
| 320 |
color: white !important;
|
| 321 |
font-weight: 700 !important;
|
| 322 |
padding: 18px 40px !important;
|
|
|
|
| 324 |
border-radius: 12px !important;
|
| 325 |
border: none !important;
|
| 326 |
transition: all 0.3s ease !important;
|
| 327 |
+
box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4) !important;
|
| 328 |
}
|
| 329 |
|
| 330 |
.generate-btn:hover {
|
| 331 |
transform: translateY(-3px) !important;
|
| 332 |
+
box-shadow: 0 15px 35px rgba(79, 70, 229, 0.5) !important;
|
| 333 |
}
|
| 334 |
|
| 335 |
.secondary-btn {
|
|
|
|
| 338 |
border: 2px solid #e2e8f0 !important;
|
| 339 |
}
|
| 340 |
|
| 341 |
+
/* Gallery */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
.gallery-container {
|
| 343 |
+
background: white !important;
|
| 344 |
+
padding: 25px !important;
|
| 345 |
+
border-radius: 16px !important;
|
| 346 |
+
border: 1px solid #e5e7eb !important;
|
| 347 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.05) !important;
|
| 348 |
}
|
| 349 |
|
| 350 |
+
/* Status Box */
|
| 351 |
.status-box {
|
| 352 |
+
background: #f8fafc !important;
|
| 353 |
+
padding: 20px !important;
|
| 354 |
+
border-radius: 12px !important;
|
| 355 |
+
border-left: 5px solid #4f46e5 !important;
|
| 356 |
+
margin-bottom: 20px !important;
|
| 357 |
+
font-size: 1.1em !important;
|
| 358 |
}
|
| 359 |
|
| 360 |
+
/* Footer */
|
| 361 |
.footer {
|
| 362 |
+
text-align: center !important;
|
| 363 |
+
color: #666 !important;
|
| 364 |
+
font-size: 0.9em !important;
|
| 365 |
+
margin-top: 40px !important;
|
| 366 |
+
padding-top: 20px !important;
|
| 367 |
+
border-top: 1px solid #e5e7eb !important;
|
| 368 |
}
|
| 369 |
|
| 370 |
+
/* Make sure dark mode doesn't break our beauty */
|
| 371 |
+
.dark .input-section,
|
| 372 |
+
.dark .gallery-container {
|
| 373 |
+
background: #1f2937 !important;
|
| 374 |
+
border-color: #374151 !important;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
.dark .example-card {
|
| 378 |
+
background: #374151 !important;
|
| 379 |
+
border-color: #4b5563 !important;
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
.dark .status-box {
|
| 383 |
+
background: #374151 !important;
|
| 384 |
}
|
| 385 |
"""
|
| 386 |
|
| 387 |
+
# Create the interface
|
| 388 |
+
with gr.Blocks(title="Pixazo Image Generator", theme=gr.themes.Soft()) as demo:
|
| 389 |
|
| 390 |
+
# Beautiful Header
|
| 391 |
gr.HTML("""
|
| 392 |
+
<div class="header-gradient">
|
| 393 |
<div class="header-title">
|
| 394 |
🎨 Pixazo Image Generator
|
| 395 |
</div>
|
|
|
|
| 415 |
</div>
|
| 416 |
""")
|
| 417 |
|
| 418 |
+
with gr.Row():
|
| 419 |
# Left Column - Inputs
|
| 420 |
+
with gr.Column(scale=1):
|
| 421 |
# Prompt Section
|
| 422 |
with gr.Group(elem_classes="input-section"):
|
| 423 |
+
gr.Markdown("### ✨ Image Description")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
prompt = gr.Textbox(
|
| 425 |
label="",
|
| 426 |
+
placeholder="Describe the image you want to generate...",
|
| 427 |
lines=4,
|
| 428 |
+
show_label=False
|
|
|
|
| 429 |
)
|
| 430 |
|
| 431 |
# Parameters Section
|
| 432 |
with gr.Group(elem_classes="input-section"):
|
| 433 |
+
gr.Markdown("### ⚙️ Generation Parameters")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 434 |
|
| 435 |
with gr.Row():
|
| 436 |
style_preset = gr.Dropdown(
|
| 437 |
+
label="Style Preset",
|
| 438 |
choices=[
|
| 439 |
"none", "cyberpunk", "fantasy", "anime", "photographic",
|
| 440 |
"digital-art", "comic", "3d-model", "pixel-art",
|
| 441 |
+
"isometric", "watercolor", "oil-painting", "sketch"
|
|
|
|
| 442 |
],
|
| 443 |
+
value="none"
|
|
|
|
| 444 |
)
|
| 445 |
|
| 446 |
with gr.Row():
|
| 447 |
guidance_scale = gr.Slider(
|
| 448 |
+
label="Guidance Scale",
|
| 449 |
minimum=1.0,
|
| 450 |
maximum=20.0,
|
| 451 |
value=7.5,
|
| 452 |
+
step=0.5
|
|
|
|
| 453 |
)
|
| 454 |
|
| 455 |
with gr.Row():
|
| 456 |
num_steps = gr.Slider(
|
| 457 |
+
label="Steps",
|
| 458 |
minimum=1,
|
| 459 |
+
maximum=50,
|
| 460 |
value=4,
|
| 461 |
+
step=1
|
|
|
|
| 462 |
)
|
| 463 |
|
| 464 |
seed = gr.Number(
|
| 465 |
+
label="Seed",
|
| 466 |
value=42,
|
| 467 |
minimum=0,
|
| 468 |
+
maximum=999999
|
|
|
|
| 469 |
)
|
| 470 |
|
| 471 |
with gr.Row():
|
| 472 |
width = gr.Slider(
|
| 473 |
+
label="Width",
|
| 474 |
minimum=256,
|
| 475 |
+
maximum=1024,
|
| 476 |
value=512,
|
| 477 |
+
step=64
|
|
|
|
| 478 |
)
|
| 479 |
|
| 480 |
height = gr.Slider(
|
| 481 |
+
label="Height",
|
| 482 |
minimum=256,
|
| 483 |
+
maximum=1024,
|
| 484 |
value=512,
|
| 485 |
+
step=64
|
|
|
|
| 486 |
)
|
| 487 |
|
| 488 |
num_images = gr.Slider(
|
| 489 |
+
label="Number of Images",
|
| 490 |
minimum=1,
|
| 491 |
maximum=8,
|
| 492 |
value=1,
|
| 493 |
+
step=1
|
|
|
|
| 494 |
)
|
| 495 |
|
| 496 |
# Action Buttons
|
|
|
|
| 498 |
generate_btn = gr.Button(
|
| 499 |
"✨ Generate Images",
|
| 500 |
variant="primary",
|
| 501 |
+
elem_classes="generate-btn",
|
| 502 |
+
scale=2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
)
|
| 504 |
+
clear_btn = gr.Button("🗑️ Clear", variant="secondary", scale=1)
|
| 505 |
|
| 506 |
# Examples Section
|
| 507 |
with gr.Group(elem_classes="input-section"):
|
| 508 |
+
gr.Markdown("### 💡 Example Prompts")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
|
| 510 |
examples = [
|
| 511 |
+
("Cyberpunk City", "A futuristic cyberpunk city at night with neon signs and flying cars", "cyberpunk"),
|
| 512 |
+
("Fantasy Dragon", "A majestic dragon on a mountain peak overlooking a magical kingdom", "fantasy"),
|
| 513 |
+
("Anime Character", "A cute anime girl with magical powers in a cherry blossom garden", "anime"),
|
| 514 |
+
("Space Explorer", "An astronaut on Mars with detailed reflection in visor", "photographic"),
|
| 515 |
+
("Isometric Scene", "Cozy isometric bedroom with plants and warm lighting", "isometric")
|
| 516 |
]
|
| 517 |
|
| 518 |
for title, desc, style in examples:
|
| 519 |
+
# Create example buttons
|
| 520 |
+
btn = gr.Button(
|
| 521 |
+
f"📌 {title}",
|
|
|
|
| 522 |
variant="secondary",
|
| 523 |
+
size="sm",
|
| 524 |
elem_classes="example-card"
|
| 525 |
)
|
| 526 |
|
| 527 |
def use_example(p=desc, s=style):
|
| 528 |
return p, s
|
| 529 |
|
| 530 |
+
btn.click(
|
| 531 |
use_example,
|
| 532 |
outputs=[prompt, style_preset]
|
| 533 |
)
|
| 534 |
|
| 535 |
# Right Column - Outputs
|
| 536 |
+
with gr.Column(scale=2):
|
| 537 |
# Status Display
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
status = gr.Textbox(
|
| 539 |
+
label="Status",
|
| 540 |
+
value="🎯 Ready to generate images. Enter a prompt above!",
|
| 541 |
interactive=False,
|
|
|
|
|
|
|
| 542 |
elem_classes="status-box"
|
| 543 |
)
|
| 544 |
|
|
|
|
| 548 |
label="🎨 Generated Images",
|
| 549 |
columns=3,
|
| 550 |
height="auto",
|
| 551 |
+
show_label=True
|
|
|
|
|
|
|
| 552 |
)
|
| 553 |
|
| 554 |
+
# Info Tabs
|
| 555 |
with gr.Tabs():
|
| 556 |
+
with gr.TabItem("📊 Response Details"):
|
| 557 |
json_output = gr.JSON(
|
| 558 |
+
label="API Response",
|
| 559 |
container=True
|
| 560 |
)
|
| 561 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
with gr.TabItem("ℹ️ About"):
|
| 563 |
gr.Markdown(f"""
|
| 564 |
+
### About This App
|
| 565 |
|
| 566 |
**Version:** 1.0.0
|
| 567 |
**Gradio:** {gr.__version__}
|
| 568 |
**API Format:** `{"output": "IMAGE_URL"}`
|
| 569 |
|
| 570 |
+
**Features:**
|
| 571 |
+
- 🖼️ Generate multiple images at once
|
| 572 |
+
- 🎭 Various style presets
|
| 573 |
+
- ⚡ Adjustable quality settings
|
| 574 |
+
- 🔒 Secure API key handling
|
| 575 |
+
- 📱 Responsive design
|
| 576 |
+
- 🔄 Real-time progress updates
|
| 577 |
|
| 578 |
**Credits:**
|
| 579 |
+
- Powered by Pixazo AI
|
| 580 |
+
- Built with Gradio
|
| 581 |
+
- Hosted on Hugging Face Spaces
|
|
|
|
|
|
|
| 582 |
""")
|
| 583 |
|
| 584 |
# Footer
|
|
|
|
| 595 |
yield None, "❌ Please enter a prompt first", {"error": "No prompt provided"}
|
| 596 |
return
|
| 597 |
|
|
|
|
| 598 |
for gallery_val, status_val, json_val in generate_images(
|
| 599 |
prompt, num_steps, seed, height, width, style_preset, num_images, guidance_scale
|
| 600 |
):
|
| 601 |
yield gallery_val, status_val, json_val
|
| 602 |
|
| 603 |
def on_clear():
|
| 604 |
+
return None, "🎯 Ready to generate images. Enter a prompt above!", None
|
| 605 |
|
| 606 |
# Connect buttons
|
| 607 |
generate_btn.click(
|
|
|
|
| 615 |
outputs=[gallery, status, json_output]
|
| 616 |
)
|
| 617 |
|
| 618 |
+
# Launch with beauty preserved! 🎨
|
| 619 |
if __name__ == "__main__":
|
| 620 |
print("=" * 60)
|
| 621 |
+
print("🚀 Launching Pixazo Image Generator")
|
| 622 |
+
print("🎨 Beautiful UI Version")
|
| 623 |
print(f"📦 Gradio Version: {gr.__version__}")
|
| 624 |
+
print(f"🔑 API Key: {'✅ Configured' if get_api_key() else '❌ Not Configured'}")
|
| 625 |
print("=" * 60)
|
| 626 |
|
|
|
|
| 627 |
demo.launch(
|
| 628 |
server_name="0.0.0.0",
|
| 629 |
server_port=7860,
|