Spaces:
Runtime error
Runtime error
anbucur
commited on
Commit
·
e502d15
1
Parent(s):
d81760a
Refactor UI layout and enhance design options in app.py
Browse files- Streamlined the user interface by reorganizing layout and improving dropdown options for room types, floor materials, wall treatments, and decorative elements.
- Introduced new choices for floor and wall options, including various materials, colors, and patterns, enhancing user customization capabilities.
- Updated the prompt generation logic to ensure valid selections and improve overall user experience.
- Removed redundant code and improved clarity in the UI component structure.
app.py
CHANGED
|
@@ -20,663 +20,429 @@ from model import DesignModel
|
|
| 20 |
from mock_model import MockDesignModel
|
| 21 |
|
| 22 |
def create_ui(model: DesignModel):
|
| 23 |
-
"""Create the
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
color: var(--body-text-color) !important;
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
/* Panel styling */
|
| 71 |
-
.gr-group {
|
| 72 |
-
border: 1px solid var(--border-color-primary);
|
| 73 |
-
border-radius: var(--radius-lg);
|
| 74 |
-
padding: var(--section-spacing);
|
| 75 |
-
margin: var(--spacing-sm) 0;
|
| 76 |
-
background: var(--background-fill-primary);
|
| 77 |
-
min-height: var(--panel-min-height);
|
| 78 |
-
height: auto !important;
|
| 79 |
-
display: flex;
|
| 80 |
-
flex-direction: column;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
/* Form and input spacing */
|
| 84 |
-
.gr-form {
|
| 85 |
-
gap: var(--spacing-sm);
|
| 86 |
-
flex-grow: 1;
|
| 87 |
-
display: flex;
|
| 88 |
-
flex-direction: column;
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
.gr-form > div {
|
| 92 |
-
gap: var(--spacing-sm);
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
/* Dropdown styling */
|
| 96 |
-
.gr-dropdown {
|
| 97 |
-
margin-bottom: var(--spacing-sm);
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
/* Gallery improvements */
|
| 101 |
-
#gallery {
|
| 102 |
-
margin-top: 0;
|
| 103 |
-
height: 300px !important;
|
| 104 |
-
}
|
| 105 |
-
|
| 106 |
-
#gallery img {
|
| 107 |
-
object-fit: contain !important;
|
| 108 |
-
width: 100% !important;
|
| 109 |
-
height: 100% !important;
|
| 110 |
-
max-height: none !important;
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
/* Button styling */
|
| 114 |
-
.button-row {
|
| 115 |
-
display: flex;
|
| 116 |
-
justify-content: center;
|
| 117 |
-
padding: var(--spacing-xl) 0;
|
| 118 |
-
}
|
| 119 |
-
|
| 120 |
-
.button-row button {
|
| 121 |
-
min-width: 200px;
|
| 122 |
-
font-size: 1.1em;
|
| 123 |
-
font-weight: 600;
|
| 124 |
-
}
|
| 125 |
-
|
| 126 |
-
/* Text areas */
|
| 127 |
-
.gr-textarea {
|
| 128 |
-
font-family: monospace;
|
| 129 |
-
line-height: 1.4;
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
.gr-textarea:disabled {
|
| 133 |
-
opacity: 0.9;
|
| 134 |
-
background-color: var(--background-fill-secondary);
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
-
/* Progress indicator */
|
| 138 |
-
.progress-bar {
|
| 139 |
-
margin: var(--spacing-sm) 0;
|
| 140 |
-
}
|
| 141 |
-
|
| 142 |
-
/* Make dropdowns always visible */
|
| 143 |
-
.gr-dropdown {
|
| 144 |
-
display: block !important;
|
| 145 |
-
visibility: visible !important;
|
| 146 |
-
}
|
| 147 |
-
|
| 148 |
-
/* Upload area */
|
| 149 |
-
.upload-group {
|
| 150 |
-
height: 100%;
|
| 151 |
-
}
|
| 152 |
-
|
| 153 |
-
.upload-group .gr-image {
|
| 154 |
-
min-height: 300px;
|
| 155 |
-
}
|
| 156 |
-
|
| 157 |
-
/* Checkbox alignment */
|
| 158 |
-
.gr-checkbox-row {
|
| 159 |
-
display: flex !important;
|
| 160 |
-
align-items: center !important;
|
| 161 |
-
min-height: 4.5rem !important;
|
| 162 |
-
}
|
| 163 |
-
|
| 164 |
-
.gr-checkbox-row .gr-checkbox {
|
| 165 |
-
margin: auto 0 !important;
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
/* Remove any fixed heights from groups */
|
| 169 |
-
.gr-group > div {
|
| 170 |
-
height: auto !important;
|
| 171 |
-
min-height: unset !important;
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
/* Ensure consistent spacing in all panels */
|
| 175 |
-
.gr-group > div:not(:last-child) {
|
| 176 |
-
margin-bottom: var(--spacing-sm);
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
/* Make surface finishes more compact */
|
| 180 |
-
.surface-finishes {
|
| 181 |
-
padding: var(--spacing-xs) !important;
|
| 182 |
-
margin: 0 !important;
|
| 183 |
-
border: 1px solid var(--border-color-primary) !important;
|
| 184 |
-
border-radius: var(--radius-lg) !important;
|
| 185 |
-
background: var(--background-fill-primary) !important;
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
.surface-finishes .gr-form {
|
| 189 |
-
gap: var(--spacing-xs) !important;
|
| 190 |
-
margin: 0 !important;
|
| 191 |
-
padding: 0 !important;
|
| 192 |
-
flex-grow: 0 !important;
|
| 193 |
-
}
|
| 194 |
-
|
| 195 |
-
.surface-finishes .gr-dropdown {
|
| 196 |
-
margin: 0 0 var(--spacing-xs) 0 !important;
|
| 197 |
-
}
|
| 198 |
-
|
| 199 |
-
.surface-finishes .gr-row {
|
| 200 |
-
margin: 0 !important;
|
| 201 |
-
gap: var(--spacing-sm) !important;
|
| 202 |
-
}
|
| 203 |
-
|
| 204 |
-
.surface-finishes .gr-group {
|
| 205 |
-
padding: 0 !important;
|
| 206 |
-
margin: 0 !important;
|
| 207 |
-
border: none !important;
|
| 208 |
-
background: none !important;
|
| 209 |
-
box-shadow: none !important;
|
| 210 |
-
min-height: 0 !important;
|
| 211 |
-
}
|
| 212 |
-
|
| 213 |
-
.surface-finishes .gr-markdown {
|
| 214 |
-
margin: 0 0 var(--spacing-xs) 0 !important;
|
| 215 |
-
}
|
| 216 |
-
|
| 217 |
-
.surface-finishes .gr-form > div {
|
| 218 |
-
gap: var(--spacing-xs) !important;
|
| 219 |
-
margin: 0 !important;
|
| 220 |
-
}
|
| 221 |
-
|
| 222 |
-
.surface-finishes .gr-column {
|
| 223 |
-
flex-grow: 0 !important;
|
| 224 |
-
padding: 0 !important;
|
| 225 |
-
}
|
| 226 |
-
|
| 227 |
-
/* Remove any minimum heights */
|
| 228 |
-
.surface-finishes .gr-group > div {
|
| 229 |
-
min-height: 0 !important;
|
| 230 |
-
height: auto !important;
|
| 231 |
-
margin: 0 !important;
|
| 232 |
-
}
|
| 233 |
-
|
| 234 |
-
/* Override any flex growth */
|
| 235 |
-
.surface-finishes .gr-form,
|
| 236 |
-
.surface-finishes .gr-column,
|
| 237 |
-
.surface-finishes .gr-group {
|
| 238 |
-
flex: 0 0 auto !important;
|
| 239 |
-
}
|
| 240 |
-
|
| 241 |
-
/* Wall decorations and special requests */
|
| 242 |
-
.wall-decorations-row > .gr-column > .gr-group {
|
| 243 |
-
height: 100%;
|
| 244 |
-
}
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
""") as interface:
|
| 251 |
-
gr.Markdown("### Interior Design Assistant")
|
| 252 |
-
|
| 253 |
-
with gr.Blocks():
|
| 254 |
-
# Row 1 - Basic Settings
|
| 255 |
-
with gr.Row():
|
| 256 |
with gr.Group():
|
| 257 |
-
gr.Markdown("##
|
| 258 |
-
|
| 259 |
-
room_type = gr.Dropdown(
|
| 260 |
choices=[
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
|
|
|
| 268 |
)
|
| 269 |
-
|
| 270 |
choices=[
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
label="Design Style",
|
| 281 |
-
value="Modern"
|
| 282 |
)
|
| 283 |
-
|
| 284 |
choices=[
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
label="Color Mood",
|
| 296 |
-
value="Neutral"
|
| 297 |
-
)
|
| 298 |
-
|
| 299 |
-
# Row 2 - Surface Finishes
|
| 300 |
-
with gr.Row():
|
| 301 |
-
# Floor Options
|
| 302 |
-
with gr.Column(scale=1):
|
| 303 |
-
with gr.Group():
|
| 304 |
-
gr.Markdown("## 🎨 Floor Options")
|
| 305 |
-
floor_type = gr.Dropdown(
|
| 306 |
-
choices=[
|
| 307 |
-
"Keep Existing", "Hardwood", "Stone Tiles", "Porcelain Tiles",
|
| 308 |
-
"Soft Carpet", "Polished Concrete", "Marble", "Vinyl",
|
| 309 |
-
"Natural Bamboo", "Cork", "Ceramic Tiles", "Terrazzo",
|
| 310 |
-
"Slate", "Travertine", "Laminate", "Engineered Wood",
|
| 311 |
-
"Mosaic Tiles", "Luxury Vinyl Tiles", "Stained Concrete"
|
| 312 |
-
],
|
| 313 |
-
label="Material",
|
| 314 |
-
value="Keep Existing"
|
| 315 |
-
)
|
| 316 |
-
floor_color = gr.Dropdown(
|
| 317 |
-
choices=[
|
| 318 |
-
"Keep Existing", "Light Oak", "Rich Walnut", "Cool Gray",
|
| 319 |
-
"Whitewashed", "Warm Cherry", "Deep Brown", "Classic Black",
|
| 320 |
-
"Natural", "Sandy Beige", "Chocolate", "Espresso",
|
| 321 |
-
"Honey Oak", "Weathered Gray", "White Marble",
|
| 322 |
-
"Cream Travertine", "Dark Slate", "Golden Teak",
|
| 323 |
-
"Rustic Pine", "Ebony"
|
| 324 |
-
],
|
| 325 |
-
label="Color",
|
| 326 |
-
value="Keep Existing"
|
| 327 |
-
)
|
| 328 |
-
floor_pattern = gr.Dropdown(
|
| 329 |
-
choices=[
|
| 330 |
-
"Keep Existing", "Classic Straight", "Elegant Herringbone",
|
| 331 |
-
"V-Pattern", "Decorative Parquet", "Diagonal Layout",
|
| 332 |
-
"Basketweave", "Chevron", "Random Length", "Grid Pattern",
|
| 333 |
-
"Versailles Pattern", "Running Bond", "Hexagonal",
|
| 334 |
-
"Moroccan Pattern", "Brick Layout", "Diamond Pattern",
|
| 335 |
-
"Windmill Pattern", "Large Format", "Mixed Width"
|
| 336 |
-
],
|
| 337 |
-
label="Pattern",
|
| 338 |
-
value="Keep Existing"
|
| 339 |
-
)
|
| 340 |
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
art_print_color = gr.Dropdown(
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
)
|
| 406 |
art_print_size = gr.Dropdown(
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
mirror_frame = gr.Dropdown(
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
)
|
| 430 |
mirror_size = gr.Dropdown(
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
sconce_color = gr.Dropdown(
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
)
|
| 457 |
sconce_style = gr.Dropdown(
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
shelf_color = gr.Dropdown(
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
)
|
| 484 |
shelf_size = gr.Dropdown(
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
)
|
| 494 |
|
| 495 |
# Plants
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
plants_type = gr.Dropdown(
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
)
|
| 511 |
plants_size = gr.Dropdown(
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
)
|
| 521 |
-
|
| 522 |
-
# Special Requests and Advanced Settings
|
| 523 |
-
with gr.Column(scale=1):
|
| 524 |
-
with gr.Group():
|
| 525 |
-
gr.Markdown("## ✨ Special Requests")
|
| 526 |
-
input_text = gr.Textbox(
|
| 527 |
-
label="Additional Details",
|
| 528 |
-
placeholder="Add any special requests or details here...",
|
| 529 |
-
lines=3
|
| 530 |
-
)
|
| 531 |
-
num_outputs = gr.Slider(
|
| 532 |
-
minimum=1, maximum=50, value=1, step=1,
|
| 533 |
-
label="Number of Variations"
|
| 534 |
-
)
|
| 535 |
-
|
| 536 |
-
gr.Markdown("### Advanced Settings")
|
| 537 |
-
num_steps = gr.Slider(
|
| 538 |
-
minimum=20,
|
| 539 |
-
maximum=100,
|
| 540 |
-
value=50,
|
| 541 |
-
step=1,
|
| 542 |
-
label="Quality Steps"
|
| 543 |
-
)
|
| 544 |
-
guidance_scale = gr.Slider(
|
| 545 |
-
minimum=1,
|
| 546 |
-
maximum=20,
|
| 547 |
-
value=7.5,
|
| 548 |
-
step=0.1,
|
| 549 |
-
label="Design Freedom"
|
| 550 |
-
)
|
| 551 |
-
strength = gr.Slider(
|
| 552 |
-
minimum=0.1,
|
| 553 |
-
maximum=1.0,
|
| 554 |
-
value=0.75,
|
| 555 |
-
step=0.05,
|
| 556 |
-
label="Change Amount"
|
| 557 |
-
)
|
| 558 |
-
seed = gr.Number(
|
| 559 |
-
label="Seed (leave empty for random)",
|
| 560 |
-
value=-1,
|
| 561 |
-
precision=0
|
| 562 |
-
)
|
| 563 |
-
with gr.Row():
|
| 564 |
-
save_to_drive = gr.Checkbox(label="Save to Google Drive")
|
| 565 |
-
drive_url = gr.Textbox(
|
| 566 |
-
label="Drive Folder URL",
|
| 567 |
-
placeholder="https://drive.google.com/drive/folders/..."
|
| 568 |
)
|
| 569 |
|
| 570 |
-
#
|
| 571 |
-
|
| 572 |
with gr.Group():
|
| 573 |
-
gr.Markdown("##
|
| 574 |
-
|
| 575 |
-
label="
|
| 576 |
-
|
| 577 |
-
lines=3
|
| 578 |
-
value="Your design prompt will appear here..."
|
| 579 |
)
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
lines=2,
|
| 584 |
-
interactive=False
|
| 585 |
)
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 611 |
)
|
| 612 |
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
try:
|
| 623 |
-
# OAuth 2.0 scopes
|
| 624 |
-
SCOPES = ['https://www.googleapis.com/auth/drive.file']
|
| 625 |
-
|
| 626 |
-
# Start OAuth 2.0 flow
|
| 627 |
-
flow = InstalledAppFlow.from_client_secrets_file(
|
| 628 |
-
'credentials.json',
|
| 629 |
-
SCOPES
|
| 630 |
)
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
# Convert numpy array to bytes
|
| 637 |
-
img = Image.fromarray(image)
|
| 638 |
-
img_byte_arr = BytesIO()
|
| 639 |
-
img.save(img_byte_arr, format='PNG')
|
| 640 |
-
img_byte_arr.seek(0)
|
| 641 |
-
|
| 642 |
-
# Prepare the file metadata
|
| 643 |
-
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 644 |
-
file_metadata = {
|
| 645 |
-
'name': f'design_variation_{timestamp}.png',
|
| 646 |
-
'parents': [folder_id]
|
| 647 |
-
}
|
| 648 |
-
|
| 649 |
-
# Create media
|
| 650 |
-
media = MediaIoBaseUpload(
|
| 651 |
-
img_byte_arr,
|
| 652 |
-
mimetype='image/png',
|
| 653 |
-
resumable=True
|
| 654 |
)
|
| 655 |
-
|
| 656 |
-
# Execute the upload
|
| 657 |
-
file = service.files().create(
|
| 658 |
-
body=file_metadata,
|
| 659 |
-
media_body=media,
|
| 660 |
-
fields='id'
|
| 661 |
-
).execute()
|
| 662 |
-
|
| 663 |
-
print(f"File uploaded successfully. File ID: {file.get('id')}")
|
| 664 |
-
return True
|
| 665 |
-
|
| 666 |
-
except Exception as e:
|
| 667 |
-
print(f"Error uploading to Drive: {e}")
|
| 668 |
-
return False
|
| 669 |
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 680 |
|
| 681 |
def on_submit(image, room, style, colors, floor_t, floor_c, floor_p,
|
| 682 |
wall_t, wall_c, wall_f, custom_text,
|
|
@@ -692,8 +458,6 @@ def create_ui(model: DesignModel):
|
|
| 692 |
return []
|
| 693 |
|
| 694 |
try:
|
| 695 |
-
nonlocal current_variations
|
| 696 |
-
|
| 697 |
# Generate the prompt
|
| 698 |
prompt = update_prompt(
|
| 699 |
room, style, colors, floor_t, floor_c, floor_p,
|
|
@@ -708,17 +472,14 @@ def create_ui(model: DesignModel):
|
|
| 708 |
# Generate variations
|
| 709 |
variations = model.generate_design(
|
| 710 |
image=image,
|
| 711 |
-
num_variations=max(1, int(num_outputs)),
|
| 712 |
prompt=prompt,
|
|
|
|
| 713 |
num_steps=int(num_steps),
|
| 714 |
guidance_scale=float(guidance_scale),
|
| 715 |
strength=float(strength),
|
| 716 |
seed=int(seed) if seed != -1 else None
|
| 717 |
)
|
| 718 |
|
| 719 |
-
# Store variations
|
| 720 |
-
current_variations = variations
|
| 721 |
-
|
| 722 |
# Handle Google Drive upload if enabled
|
| 723 |
if save_to_drive and drive_url:
|
| 724 |
folder_id = extract_folder_id(drive_url)
|
|
@@ -732,7 +493,6 @@ def create_ui(model: DesignModel):
|
|
| 732 |
|
| 733 |
except Exception as e:
|
| 734 |
print(f"Error in generation: {e}")
|
| 735 |
-
current_variations = []
|
| 736 |
return []
|
| 737 |
|
| 738 |
submit.click(
|
|
@@ -783,97 +543,8 @@ def create_ui(model: DesignModel):
|
|
| 783 |
outputs=[prompt_display, negative_prompt]
|
| 784 |
)
|
| 785 |
|
| 786 |
-
# Gallery click handler
|
| 787 |
-
def on_select(evt):
|
| 788 |
-
nonlocal current_variations
|
| 789 |
-
try:
|
| 790 |
-
if isinstance(evt, list) and len(evt) > 0:
|
| 791 |
-
# Get the clicked file path
|
| 792 |
-
clicked_path = evt[0][0] if isinstance(evt[0], tuple) else evt[0]
|
| 793 |
-
|
| 794 |
-
# Get all file paths from the gallery
|
| 795 |
-
gallery_paths = []
|
| 796 |
-
for item in evt:
|
| 797 |
-
path = item[0] if isinstance(item, tuple) else item
|
| 798 |
-
gallery_paths.append(path)
|
| 799 |
-
|
| 800 |
-
# Find which image was clicked by comparing paths
|
| 801 |
-
selected_index = gallery_paths.index(clicked_path)
|
| 802 |
-
if 0 <= selected_index < len(current_variations):
|
| 803 |
-
return current_variations[selected_index]
|
| 804 |
-
except Exception as e:
|
| 805 |
-
print(f"Gallery selection error: {e}")
|
| 806 |
-
return None
|
| 807 |
-
|
| 808 |
-
gallery.select(
|
| 809 |
-
fn=on_select,
|
| 810 |
-
inputs=gallery,
|
| 811 |
-
outputs=[]
|
| 812 |
-
)
|
| 813 |
-
|
| 814 |
return interface
|
| 815 |
|
| 816 |
-
def update_prompt(room, style, colors, floor_t, floor_c, floor_p,
|
| 817 |
-
wall_t, wall_c, wall_f, custom_text,
|
| 818 |
-
art_en, art_col, art_size,
|
| 819 |
-
mirror_en, mirror_fr, mirror_size,
|
| 820 |
-
sconce_en, sconce_col, sconce_style,
|
| 821 |
-
shelf_en, shelf_col, shelf_size,
|
| 822 |
-
plants_en, plants_type, plants_size):
|
| 823 |
-
# Start with basic room, style, and color scheme (these should always be included as they have valid defaults)
|
| 824 |
-
prompt_parts = [f"Design a {style} {room.lower()} with a {colors} color scheme"]
|
| 825 |
-
|
| 826 |
-
# Add floor details only if not "Keep Existing" or "None"
|
| 827 |
-
if floor_t not in ["Keep Existing", "None"]:
|
| 828 |
-
floor_desc = floor_t
|
| 829 |
-
if floor_c not in ["Keep Existing", "None"]:
|
| 830 |
-
floor_desc += f" in {floor_c}"
|
| 831 |
-
if floor_p not in ["Keep Existing", "None"]:
|
| 832 |
-
floor_desc += f" with {floor_p} pattern"
|
| 833 |
-
prompt_parts.append(f"featuring {floor_desc} flooring")
|
| 834 |
-
|
| 835 |
-
# Add wall details only if not "Keep Existing" or "None"
|
| 836 |
-
if wall_t not in ["Keep Existing", "None"]:
|
| 837 |
-
wall_desc = wall_t
|
| 838 |
-
if wall_c not in ["Keep Existing", "None"]:
|
| 839 |
-
wall_desc += f" in {wall_c}"
|
| 840 |
-
if wall_f not in ["Keep Existing", "None"]:
|
| 841 |
-
wall_desc += f" with {wall_f} finish"
|
| 842 |
-
prompt_parts.append(f"with {wall_desc} walls")
|
| 843 |
-
|
| 844 |
-
# Add accessories only if enabled AND properties are not "Keep Existing" or "None"
|
| 845 |
-
accessories = []
|
| 846 |
-
|
| 847 |
-
# Art Print
|
| 848 |
-
if art_en and art_col not in ["Keep Existing", "None"] and art_size not in ["Keep Existing", "None"]:
|
| 849 |
-
accessories.append(f"{art_size} {art_col} Art Print")
|
| 850 |
-
|
| 851 |
-
# Mirror
|
| 852 |
-
if mirror_en and mirror_fr not in ["Keep Existing", "None"] and mirror_size not in ["Keep Existing", "None"]:
|
| 853 |
-
accessories.append(f"{mirror_size} Mirror with {mirror_fr} frame")
|
| 854 |
-
|
| 855 |
-
# Wall Sconce
|
| 856 |
-
if sconce_en and sconce_col not in ["Keep Existing", "None"] and sconce_style not in ["Keep Existing", "None"]:
|
| 857 |
-
accessories.append(f"{sconce_style} {sconce_col} Wall Sconce")
|
| 858 |
-
|
| 859 |
-
# Floating Shelves
|
| 860 |
-
if shelf_en and shelf_col not in ["Keep Existing", "None"] and shelf_size not in ["Keep Existing", "None"]:
|
| 861 |
-
accessories.append(f"{shelf_size} {shelf_col} Floating Shelves")
|
| 862 |
-
|
| 863 |
-
# Wall Plants
|
| 864 |
-
if plants_en and plants_type not in ["Keep Existing", "None"] and plants_size not in ["Keep Existing", "None"]:
|
| 865 |
-
accessories.append(f"{plants_size} {plants_type}")
|
| 866 |
-
|
| 867 |
-
# Only add accessories section if there are any accessories
|
| 868 |
-
if accessories:
|
| 869 |
-
prompt_parts.append("decorated with " + ", ".join(accessories))
|
| 870 |
-
|
| 871 |
-
# Add custom text only if provided and non-empty
|
| 872 |
-
if custom_text and custom_text.strip():
|
| 873 |
-
prompt_parts.append(custom_text.strip())
|
| 874 |
-
|
| 875 |
-
return ", ".join(prompt_parts)
|
| 876 |
-
|
| 877 |
def main():
|
| 878 |
"""Main entry point for the application"""
|
| 879 |
import sys
|
|
@@ -882,9 +553,9 @@ def main():
|
|
| 882 |
is_test_mode = "--test" in sys.argv
|
| 883 |
|
| 884 |
if is_test_mode:
|
| 885 |
-
|
| 886 |
from mock_model import MockDesignModel
|
| 887 |
-
|
| 888 |
else:
|
| 889 |
print("Starting in PRODUCTION mode...")
|
| 890 |
from prod_model import ProductionDesignModel
|
|
|
|
| 20 |
from mock_model import MockDesignModel
|
| 21 |
|
| 22 |
def create_ui(model: DesignModel):
|
| 23 |
+
"""Create the user interface for the application"""
|
| 24 |
+
with gr.Blocks() as interface:
|
| 25 |
+
gr.Markdown("## 🏠 Basic Settings")
|
| 26 |
+
with gr.Row():
|
| 27 |
+
with gr.Column():
|
| 28 |
+
room_type = gr.Dropdown(
|
| 29 |
+
choices=[
|
| 30 |
+
"None", "Living Room", "Bedroom", "Dining Room", "Kitchen",
|
| 31 |
+
"Bathroom", "Home Office", "Master Bedroom", "Guest Room",
|
| 32 |
+
"Family Room", "Study", "Game Room", "Library",
|
| 33 |
+
"Nursery", "Craft Room"
|
| 34 |
+
],
|
| 35 |
+
label="Room Type",
|
| 36 |
+
value="None"
|
| 37 |
+
)
|
| 38 |
+
style_preset = gr.Dropdown(
|
| 39 |
+
choices=[
|
| 40 |
+
"None", "Modern", "Contemporary", "Minimalist", "Industrial",
|
| 41 |
+
"Scandinavian", "Mid-Century Modern", "Traditional",
|
| 42 |
+
"Transitional", "Farmhouse", "Rustic", "Bohemian",
|
| 43 |
+
"Art Deco", "Coastal", "Mediterranean", "Japanese",
|
| 44 |
+
"French Country", "Victorian", "Colonial", "Gothic",
|
| 45 |
+
"Baroque", "Rococo", "Neoclassical", "Eclectic",
|
| 46 |
+
"Zen", "Tropical", "Shabby Chic", "Hollywood Regency",
|
| 47 |
+
"Southwestern", "Asian Fusion", "Retro"
|
| 48 |
+
],
|
| 49 |
+
label="Design Style",
|
| 50 |
+
value="None"
|
| 51 |
+
)
|
| 52 |
+
color_scheme = gr.Dropdown(
|
| 53 |
+
choices=[
|
| 54 |
+
"None", "Neutral", "Monochromatic", "Minimalist White",
|
| 55 |
+
"Warm Gray", "Cool Gray", "Earth Tones",
|
| 56 |
+
"Pastel", "Bold Primary", "Jewel Tones",
|
| 57 |
+
"Black and White", "Navy and Gold", "Forest Green",
|
| 58 |
+
"Desert Sand", "Ocean Blue", "Sunset Orange",
|
| 59 |
+
"Deep Purple", "Emerald Green", "Ruby Red",
|
| 60 |
+
"Sapphire Blue", "Golden Yellow", "Sage Green",
|
| 61 |
+
"Dusty Rose", "Charcoal", "Cream", "Burgundy",
|
| 62 |
+
"Teal", "Copper", "Silver", "Bronze", "Slate"
|
| 63 |
+
],
|
| 64 |
+
label="Color Mood",
|
| 65 |
+
value="None"
|
| 66 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
# Row 2 - Surface Finishes
|
| 69 |
+
with gr.Row():
|
| 70 |
+
# Floor Options
|
| 71 |
+
with gr.Column(scale=1):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
with gr.Group():
|
| 73 |
+
gr.Markdown("## 🎨 Floor Options")
|
| 74 |
+
floor_type = gr.Dropdown(
|
|
|
|
| 75 |
choices=[
|
| 76 |
+
"Keep Existing", "Hardwood", "Stone Tiles", "Porcelain Tiles",
|
| 77 |
+
"Soft Carpet", "Polished Concrete", "Marble", "Vinyl",
|
| 78 |
+
"Natural Bamboo", "Cork", "Ceramic Tiles", "Terrazzo",
|
| 79 |
+
"Slate", "Travertine", "Laminate", "Engineered Wood",
|
| 80 |
+
"Mosaic Tiles", "Luxury Vinyl Tiles", "Stained Concrete"
|
| 81 |
+
],
|
| 82 |
+
label="Material",
|
| 83 |
+
value="Keep Existing"
|
| 84 |
)
|
| 85 |
+
floor_color = gr.Dropdown(
|
| 86 |
choices=[
|
| 87 |
+
"Keep Existing", "Light Oak", "Rich Walnut", "Cool Gray",
|
| 88 |
+
"Whitewashed", "Warm Cherry", "Deep Brown", "Classic Black",
|
| 89 |
+
"Natural", "Sandy Beige", "Chocolate", "Espresso",
|
| 90 |
+
"Honey Oak", "Weathered Gray", "White Marble",
|
| 91 |
+
"Cream Travertine", "Dark Slate", "Golden Teak",
|
| 92 |
+
"Rustic Pine", "Ebony"
|
| 93 |
+
],
|
| 94 |
+
label="Color",
|
| 95 |
+
value="Keep Existing"
|
|
|
|
|
|
|
| 96 |
)
|
| 97 |
+
floor_pattern = gr.Dropdown(
|
| 98 |
choices=[
|
| 99 |
+
"Keep Existing", "Classic Straight", "Elegant Herringbone",
|
| 100 |
+
"V-Pattern", "Decorative Parquet", "Diagonal Layout",
|
| 101 |
+
"Basketweave", "Chevron", "Random Length", "Grid Pattern",
|
| 102 |
+
"Versailles Pattern", "Running Bond", "Hexagonal",
|
| 103 |
+
"Moroccan Pattern", "Brick Layout", "Diamond Pattern",
|
| 104 |
+
"Windmill Pattern", "Large Format", "Mixed Width"
|
| 105 |
+
],
|
| 106 |
+
label="Pattern",
|
| 107 |
+
value="Keep Existing"
|
| 108 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
+
# Wall Options
|
| 111 |
+
with gr.Column(scale=1):
|
| 112 |
+
with gr.Group():
|
| 113 |
+
gr.Markdown("## 🎨 Wall Options")
|
| 114 |
+
wall_type = gr.Dropdown(
|
| 115 |
+
choices=[
|
| 116 |
+
"Keep Existing", "Fresh Paint", "Designer Wallpaper",
|
| 117 |
+
"Textured Finish", "Wood Panels", "Exposed Brick",
|
| 118 |
+
"Natural Stone", "Wooden Planks", "Modern Concrete",
|
| 119 |
+
"Venetian Plaster", "Wainscoting", "Shiplap",
|
| 120 |
+
"3D Wall Panels", "Fabric Panels", "Metal Panels",
|
| 121 |
+
"Cork Wall", "Tile Feature", "Glass Panels",
|
| 122 |
+
"Acoustic Panels", "Living Wall"
|
| 123 |
+
],
|
| 124 |
+
label="Treatment",
|
| 125 |
+
value="Keep Existing"
|
| 126 |
+
)
|
| 127 |
+
wall_color = gr.Dropdown(
|
| 128 |
+
choices=[
|
| 129 |
+
"Keep Existing", "Crisp White", "Soft White", "Warm Beige",
|
| 130 |
+
"Gentle Gray", "Sky Blue", "Nature Green", "Sunny Yellow",
|
| 131 |
+
"Blush Pink", "Deep Blue", "Bold Black", "Sage Green",
|
| 132 |
+
"Terracotta", "Navy Blue", "Charcoal Gray", "Lavender",
|
| 133 |
+
"Olive Green", "Dusty Rose", "Teal", "Burgundy"
|
| 134 |
+
],
|
| 135 |
+
label="Color",
|
| 136 |
+
value="Keep Existing"
|
| 137 |
+
)
|
| 138 |
+
wall_finish = gr.Dropdown(
|
| 139 |
+
choices=[
|
| 140 |
+
"Keep Existing", "Soft Matte", "Subtle Eggshell",
|
| 141 |
+
"Pearl Satin", "Sleek Semi-Gloss", "High Gloss",
|
| 142 |
+
"Suede Texture", "Metallic", "Chalk Finish",
|
| 143 |
+
"Distressed", "Brushed", "Smooth", "Textured",
|
| 144 |
+
"Venetian", "Lime Wash", "Concrete", "Rustic",
|
| 145 |
+
"Lacquered", "Hammered", "Patina"
|
| 146 |
+
],
|
| 147 |
+
label="Finish",
|
| 148 |
+
value="Keep Existing"
|
| 149 |
+
)
|
| 150 |
|
| 151 |
+
# Row 3 - Wall Decorations and Special Requests
|
| 152 |
+
with gr.Row(elem_classes="wall-decorations-row"):
|
| 153 |
+
# Wall Decorations
|
| 154 |
+
with gr.Column(scale=2):
|
| 155 |
+
with gr.Group():
|
| 156 |
+
gr.Markdown("## 🖼️ Wall Decorations")
|
| 157 |
+
# Art and Mirror
|
| 158 |
+
with gr.Row():
|
| 159 |
+
# Art Print
|
| 160 |
+
with gr.Column():
|
| 161 |
+
with gr.Row():
|
| 162 |
+
art_print_enable = gr.Checkbox(label="Add Artwork", value=False)
|
| 163 |
art_print_color = gr.Dropdown(
|
| 164 |
+
choices=[
|
| 165 |
+
"None", "Classic Black & White", "Vibrant Colors",
|
| 166 |
+
"Single Color", "Soft Colors", "Modern Abstract",
|
| 167 |
+
"Earth Tones", "Pastel Palette", "Bold Primary Colors",
|
| 168 |
+
"Metallic Accents", "Monochromatic", "Jewel Tones",
|
| 169 |
+
"Watercolor", "Vintage Colors", "Neon Accents",
|
| 170 |
+
"Natural Hues", "Ocean Colors", "Desert Palette"
|
| 171 |
+
],
|
| 172 |
+
label="Art Style",
|
| 173 |
+
value="None"
|
| 174 |
)
|
| 175 |
art_print_size = gr.Dropdown(
|
| 176 |
+
choices=[
|
| 177 |
+
"None", "Modest", "Standard", "Statement", "Oversized",
|
| 178 |
+
"Gallery Wall", "Diptych", "Triptych", "Mini Series",
|
| 179 |
+
"Floor to Ceiling", "Custom Size"
|
| 180 |
+
],
|
| 181 |
+
label="Art Size",
|
| 182 |
+
value="None"
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
# Mirror
|
| 186 |
+
with gr.Column():
|
| 187 |
+
with gr.Row():
|
| 188 |
+
mirror_enable = gr.Checkbox(label="Add Mirror", value=False)
|
| 189 |
mirror_frame = gr.Dropdown(
|
| 190 |
+
choices=[
|
| 191 |
+
"None", "Gold", "Silver", "Black", "White", "Wood",
|
| 192 |
+
"Brass", "Bronze", "Copper", "Chrome", "Antique Gold",
|
| 193 |
+
"Brushed Nickel", "Rustic Wood", "Ornate", "Minimalist",
|
| 194 |
+
"LED Backlit", "Bamboo", "Rattan", "Leather Wrapped"
|
| 195 |
+
],
|
| 196 |
+
label="Frame Style",
|
| 197 |
+
value="None"
|
| 198 |
)
|
| 199 |
mirror_size = gr.Dropdown(
|
| 200 |
+
choices=[
|
| 201 |
+
"Small", "Medium", "Large", "Full Length",
|
| 202 |
+
"Oversized", "Double Width", "Floor Mirror",
|
| 203 |
+
"Vanity Size", "Statement Piece", "Custom Size"
|
| 204 |
+
],
|
| 205 |
+
label="Mirror Size",
|
| 206 |
+
value="Medium"
|
| 207 |
+
)
|
| 208 |
|
| 209 |
+
# Sconce, Shelf, and Plants
|
| 210 |
+
with gr.Row():
|
| 211 |
+
# Sconce
|
| 212 |
+
with gr.Column():
|
| 213 |
+
with gr.Row():
|
| 214 |
+
sconce_enable = gr.Checkbox(label="Add Wall Sconce", value=False)
|
| 215 |
sconce_color = gr.Dropdown(
|
| 216 |
+
choices=[
|
| 217 |
+
"None", "Black", "Gold", "Silver", "Bronze", "White",
|
| 218 |
+
"Brass", "Copper", "Chrome", "Antique Brass",
|
| 219 |
+
"Brushed Nickel", "Oil-Rubbed Bronze", "Pewter",
|
| 220 |
+
"Rose Gold", "Matte Black", "Polished Nickel",
|
| 221 |
+
"Aged Brass", "Champagne", "Gunmetal"
|
| 222 |
+
],
|
| 223 |
+
label="Sconce Color",
|
| 224 |
+
value="None"
|
| 225 |
)
|
| 226 |
sconce_style = gr.Dropdown(
|
| 227 |
+
choices=[
|
| 228 |
+
"Modern", "Traditional", "Industrial", "Art Deco",
|
| 229 |
+
"Minimalist", "Vintage", "Contemporary", "Rustic",
|
| 230 |
+
"Coastal", "Farmhouse", "Mid-Century", "Bohemian",
|
| 231 |
+
"Scandinavian", "Asian", "Mediterranean", "Gothic",
|
| 232 |
+
"Transitional", "Eclectic", "Victorian"
|
| 233 |
+
],
|
| 234 |
+
label="Sconce Style",
|
| 235 |
+
value="Modern"
|
| 236 |
+
)
|
| 237 |
|
| 238 |
+
# Floating Shelves
|
| 239 |
+
with gr.Column():
|
| 240 |
+
with gr.Row():
|
| 241 |
+
shelf_enable = gr.Checkbox(label="Add Floating Shelves", value=False)
|
| 242 |
shelf_color = gr.Dropdown(
|
| 243 |
+
choices=[
|
| 244 |
+
"None", "White", "Black", "Natural Wood", "Glass",
|
| 245 |
+
"Dark Wood", "Light Wood", "Metal", "Gold", "Silver",
|
| 246 |
+
"Bronze", "Reclaimed Wood", "Bamboo", "Marble",
|
| 247 |
+
"Industrial Metal", "Two-Tone", "Concrete",
|
| 248 |
+
"Acrylic", "Copper", "Brass"
|
| 249 |
+
],
|
| 250 |
+
label="Shelf Material",
|
| 251 |
+
value="None"
|
| 252 |
)
|
| 253 |
shelf_size = gr.Dropdown(
|
| 254 |
+
choices=[
|
| 255 |
+
"Small", "Medium", "Large", "Set of 3",
|
| 256 |
+
"Extra Long", "Corner Set", "Asymmetric Set",
|
| 257 |
+
"Graduated Sizes", "Custom Length", "Mini Cubes",
|
| 258 |
+
"Full Wall", "Mixed Sizes", "Modular System"
|
| 259 |
+
],
|
| 260 |
+
label="Shelf Size",
|
| 261 |
+
value="Medium"
|
| 262 |
)
|
| 263 |
|
| 264 |
# Plants
|
| 265 |
+
with gr.Column():
|
| 266 |
+
with gr.Row():
|
| 267 |
+
plants_enable = gr.Checkbox(label="Add Plants", value=False)
|
| 268 |
plants_type = gr.Dropdown(
|
| 269 |
+
choices=[
|
| 270 |
+
"None", "Hanging Plants", "Vertical Garden",
|
| 271 |
+
"Plant Shelf", "Single Plant", "Climbing Vines",
|
| 272 |
+
"Air Plants", "Succulent Wall", "Herb Garden",
|
| 273 |
+
"Mixed Tropical", "Fern Collection", "Living Wall",
|
| 274 |
+
"Moss Wall", "Potted Arrangement", "Plant Corner",
|
| 275 |
+
"Cascading Plants", "Bamboo Screen", "Terrarium Wall"
|
| 276 |
+
],
|
| 277 |
+
label="Plant Type",
|
| 278 |
+
value="None"
|
| 279 |
)
|
| 280 |
plants_size = gr.Dropdown(
|
| 281 |
+
choices=[
|
| 282 |
+
"Small", "Medium", "Large", "Mixed Sizes",
|
| 283 |
+
"Full Wall", "Statement Piece", "Compact",
|
| 284 |
+
"Expansive", "Accent", "Floor to Ceiling",
|
| 285 |
+
"Window Height", "Custom Size", "Modular"
|
| 286 |
+
],
|
| 287 |
+
label="Plant Coverage",
|
| 288 |
+
value="Medium"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
)
|
| 290 |
|
| 291 |
+
# Special Requests and Advanced Settings
|
| 292 |
+
with gr.Column(scale=1):
|
| 293 |
with gr.Group():
|
| 294 |
+
gr.Markdown("## ✨ Special Requests")
|
| 295 |
+
input_text = gr.Textbox(
|
| 296 |
+
label="Additional Details",
|
| 297 |
+
placeholder="Add any special requests or details here...",
|
| 298 |
+
lines=3
|
|
|
|
| 299 |
)
|
| 300 |
+
num_outputs = gr.Slider(
|
| 301 |
+
minimum=1, maximum=50, value=1, step=1,
|
| 302 |
+
label="Number of Variations"
|
|
|
|
|
|
|
| 303 |
)
|
| 304 |
+
|
| 305 |
+
gr.Markdown("### Advanced Settings")
|
| 306 |
+
num_steps = gr.Slider(
|
| 307 |
+
minimum=20,
|
| 308 |
+
maximum=100,
|
| 309 |
+
value=50,
|
| 310 |
+
step=1,
|
| 311 |
+
label="Quality Steps"
|
| 312 |
+
)
|
| 313 |
+
guidance_scale = gr.Slider(
|
| 314 |
+
minimum=1,
|
| 315 |
+
maximum=20,
|
| 316 |
+
value=10.0,
|
| 317 |
+
step=0.1,
|
| 318 |
+
label="Design Freedom"
|
| 319 |
+
)
|
| 320 |
+
strength = gr.Slider(
|
| 321 |
+
minimum=0.1,
|
| 322 |
+
maximum=1.0,
|
| 323 |
+
value=0.9,
|
| 324 |
+
step=0.05,
|
| 325 |
+
label="Change Amount"
|
| 326 |
+
)
|
| 327 |
+
seed = gr.Number(
|
| 328 |
+
label="Seed (leave empty for random)",
|
| 329 |
+
value=-1,
|
| 330 |
+
precision=0
|
| 331 |
+
)
|
| 332 |
+
with gr.Row():
|
| 333 |
+
save_to_drive = gr.Checkbox(label="Save to Google Drive")
|
| 334 |
+
drive_url = gr.Textbox(
|
| 335 |
+
label="Drive Folder URL",
|
| 336 |
+
placeholder="https://drive.google.com/drive/folders/..."
|
| 337 |
)
|
| 338 |
|
| 339 |
+
# Row 4 - Current Prompts
|
| 340 |
+
with gr.Row():
|
| 341 |
+
with gr.Group():
|
| 342 |
+
gr.Markdown("## 📝 Current Prompts")
|
| 343 |
+
prompt_display = gr.TextArea(
|
| 344 |
+
label="Positive Prompt",
|
| 345 |
+
interactive=False,
|
| 346 |
+
lines=3,
|
| 347 |
+
value="Your design prompt will appear here..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
)
|
| 349 |
+
negative_prompt = gr.TextArea(
|
| 350 |
+
label="Negative Prompt",
|
| 351 |
+
value="blurry, low quality, distorted, deformed, disfigured, watermark, text, bad proportions, duplicate, double, multiple, broken, cropped",
|
| 352 |
+
lines=2,
|
| 353 |
+
interactive=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
|
| 356 |
+
# Row 5 - Upload and Gallery
|
| 357 |
+
with gr.Row(elem_classes="upload-gallery-row"):
|
| 358 |
+
# Upload Area
|
| 359 |
+
with gr.Column(scale=1):
|
| 360 |
+
with gr.Group():
|
| 361 |
+
gr.Markdown("## 📸 Upload Photo")
|
| 362 |
+
input_image = gr.Image(
|
| 363 |
+
label="Upload a photo of your room",
|
| 364 |
+
type='pil'
|
| 365 |
+
)
|
| 366 |
+
|
| 367 |
+
# Gallery Area
|
| 368 |
+
with gr.Column(scale=2):
|
| 369 |
+
with gr.Group():
|
| 370 |
+
gr.Markdown("## 🖼️ Generated Variations")
|
| 371 |
+
gallery = gr.Gallery(
|
| 372 |
+
show_label=False,
|
| 373 |
+
elem_id="gallery",
|
| 374 |
+
columns=4,
|
| 375 |
+
rows=1,
|
| 376 |
+
height="300px",
|
| 377 |
+
object_fit="contain",
|
| 378 |
+
preview=True,
|
| 379 |
+
show_share_button=False
|
| 380 |
+
)
|
| 381 |
+
|
| 382 |
+
# Row 6 - Create Button
|
| 383 |
+
with gr.Row(elem_classes="button-row"):
|
| 384 |
+
submit = gr.Button("✨ Create My Design", variant="primary", size="lg")
|
| 385 |
+
|
| 386 |
+
def update_prompt(room, style, colors, floor_t, floor_c, floor_p,
|
| 387 |
+
wall_t, wall_c, wall_f, custom_text,
|
| 388 |
+
art_en, art_col, art_size,
|
| 389 |
+
mirror_en, mirror_fr, mirror_size,
|
| 390 |
+
sconce_en, sconce_col, sconce_style,
|
| 391 |
+
shelf_en, shelf_col, shelf_size,
|
| 392 |
+
plants_en, plants_type, plants_size):
|
| 393 |
+
# Start with basic room, style, and color scheme (these should always be included as they have valid defaults)
|
| 394 |
+
prompt_parts = [f"Design a {style} {room.lower()} with a {colors} color scheme"]
|
| 395 |
+
|
| 396 |
+
# Add floor details only if not "Keep Existing" or "None"
|
| 397 |
+
if floor_t not in ["Keep Existing", "None"]:
|
| 398 |
+
floor_desc = floor_t
|
| 399 |
+
if floor_c not in ["Keep Existing", "None"]:
|
| 400 |
+
floor_desc += f" in {floor_c}"
|
| 401 |
+
if floor_p not in ["Keep Existing", "None"]:
|
| 402 |
+
floor_desc += f" with {floor_p} pattern"
|
| 403 |
+
prompt_parts.append(f"featuring {floor_desc} flooring")
|
| 404 |
+
|
| 405 |
+
# Add wall details only if not "Keep Existing" or "None"
|
| 406 |
+
if wall_t not in ["Keep Existing", "None"]:
|
| 407 |
+
wall_desc = wall_t
|
| 408 |
+
if wall_c not in ["Keep Existing", "None"]:
|
| 409 |
+
wall_desc += f" in {wall_c}"
|
| 410 |
+
if wall_f not in ["Keep Existing", "None"]:
|
| 411 |
+
wall_desc += f" with {wall_f} finish"
|
| 412 |
+
prompt_parts.append(f"with {wall_desc} walls")
|
| 413 |
+
|
| 414 |
+
# Add accessories only if enabled AND properties are not "Keep Existing" or "None"
|
| 415 |
+
accessories = []
|
| 416 |
+
|
| 417 |
+
# Art Print
|
| 418 |
+
if art_en and art_col not in ["Keep Existing", "None"] and art_size not in ["Keep Existing", "None"]:
|
| 419 |
+
accessories.append(f"{art_size} {art_col} Art Print")
|
| 420 |
+
|
| 421 |
+
# Mirror
|
| 422 |
+
if mirror_en and mirror_fr not in ["Keep Existing", "None"] and mirror_size not in ["Keep Existing", "None"]:
|
| 423 |
+
accessories.append(f"{mirror_size} Mirror with {mirror_fr} frame")
|
| 424 |
+
|
| 425 |
+
# Wall Sconce
|
| 426 |
+
if sconce_en and sconce_col not in ["Keep Existing", "None"] and sconce_style not in ["Keep Existing", "None"]:
|
| 427 |
+
accessories.append(f"{sconce_style} {sconce_col} Wall Sconce")
|
| 428 |
+
|
| 429 |
+
# Floating Shelves
|
| 430 |
+
if shelf_en and shelf_col not in ["Keep Existing", "None"] and shelf_size not in ["Keep Existing", "None"]:
|
| 431 |
+
accessories.append(f"{shelf_size} {shelf_col} Floating Shelves")
|
| 432 |
+
|
| 433 |
+
# Wall Plants
|
| 434 |
+
if plants_en and plants_type not in ["Keep Existing", "None"] and plants_size not in ["Keep Existing", "None"]:
|
| 435 |
+
accessories.append(f"{plants_size} {plants_type}")
|
| 436 |
+
|
| 437 |
+
# Only add accessories section if there are any accessories
|
| 438 |
+
if accessories:
|
| 439 |
+
prompt_parts.append("decorated with " + ", ".join(accessories))
|
| 440 |
+
|
| 441 |
+
# Add custom text only if provided and non-empty
|
| 442 |
+
if custom_text and custom_text.strip():
|
| 443 |
+
prompt_parts.append(custom_text.strip())
|
| 444 |
+
|
| 445 |
+
return ", ".join(prompt_parts)
|
| 446 |
|
| 447 |
def on_submit(image, room, style, colors, floor_t, floor_c, floor_p,
|
| 448 |
wall_t, wall_c, wall_f, custom_text,
|
|
|
|
| 458 |
return []
|
| 459 |
|
| 460 |
try:
|
|
|
|
|
|
|
| 461 |
# Generate the prompt
|
| 462 |
prompt = update_prompt(
|
| 463 |
room, style, colors, floor_t, floor_c, floor_p,
|
|
|
|
| 472 |
# Generate variations
|
| 473 |
variations = model.generate_design(
|
| 474 |
image=image,
|
|
|
|
| 475 |
prompt=prompt,
|
| 476 |
+
num_variations=max(1, int(num_outputs)),
|
| 477 |
num_steps=int(num_steps),
|
| 478 |
guidance_scale=float(guidance_scale),
|
| 479 |
strength=float(strength),
|
| 480 |
seed=int(seed) if seed != -1 else None
|
| 481 |
)
|
| 482 |
|
|
|
|
|
|
|
|
|
|
| 483 |
# Handle Google Drive upload if enabled
|
| 484 |
if save_to_drive and drive_url:
|
| 485 |
folder_id = extract_folder_id(drive_url)
|
|
|
|
| 493 |
|
| 494 |
except Exception as e:
|
| 495 |
print(f"Error in generation: {e}")
|
|
|
|
| 496 |
return []
|
| 497 |
|
| 498 |
submit.click(
|
|
|
|
| 543 |
outputs=[prompt_display, negative_prompt]
|
| 544 |
)
|
| 545 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 546 |
return interface
|
| 547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
def main():
|
| 549 |
"""Main entry point for the application"""
|
| 550 |
import sys
|
|
|
|
| 553 |
is_test_mode = "--test" in sys.argv
|
| 554 |
|
| 555 |
if is_test_mode:
|
| 556 |
+
print("Starting in TEST mode...")
|
| 557 |
from mock_model import MockDesignModel
|
| 558 |
+
model = MockDesignModel()
|
| 559 |
else:
|
| 560 |
print("Starting in PRODUCTION mode...")
|
| 561 |
from prod_model import ProductionDesignModel
|