anbucur commited on
Commit
8c93fbf
·
1 Parent(s): 01eb3dc

Refactor UI dropdowns and update prompt logic to include 'None' as a valid choice. Enhanced validation for floor, wall, and accessory options to prevent 'Keep Existing' or 'None' selections from being processed. This improves user experience by providing clearer options and ensuring valid inputs.

Browse files
Files changed (1) hide show
  1. app.py +21 -45
app.py CHANGED
@@ -257,43 +257,19 @@ def create_ui(model: DesignModel):
257
  gr.Markdown("## 🏠 Basic Settings")
258
  with gr.Row():
259
  room_type = gr.Dropdown(
260
- choices=[
261
- "Living Room", "Bedroom", "Kitchen", "Dining Room",
262
- "Bathroom", "Home Office", "Kids Room", "Master Bedroom",
263
- "Guest Room", "Studio Apartment", "Entryway", "Hallway",
264
- "Game Room", "Library", "Home Theater", "Gym"
265
- ],
266
  label="Room Type",
267
- value="Living Room"
 
268
  )
269
  style_preset = gr.Dropdown(
270
- choices=[
271
- "Modern", "Contemporary", "Minimalist", "Industrial",
272
- "Scandinavian", "Mid-Century Modern", "Traditional",
273
- "Transitional", "Farmhouse", "Rustic", "Bohemian",
274
- "Art Deco", "Coastal", "Mediterranean", "Japanese",
275
- "French Country", "Victorian", "Colonial", "Gothic",
276
- "Baroque", "Rococo", "Neoclassical", "Eclectic",
277
- "Zen", "Tropical", "Shabby Chic", "Hollywood Regency",
278
- "Southwestern", "Asian Fusion", "Retro"
279
- ],
280
  label="Design Style",
281
- value="Modern"
 
282
  )
283
  color_scheme = gr.Dropdown(
284
- choices=[
285
- "Neutral", "Monochromatic", "Minimalist White",
286
- "Warm Gray", "Cool Gray", "Earth Tones",
287
- "Pastel", "Bold Primary", "Jewel Tones",
288
- "Black and White", "Navy and Gold", "Forest Green",
289
- "Desert Sand", "Ocean Blue", "Sunset Orange",
290
- "Deep Purple", "Emerald Green", "Ruby Red",
291
- "Sapphire Blue", "Golden Yellow", "Sage Green",
292
- "Dusty Rose", "Charcoal", "Cream", "Burgundy",
293
- "Teal", "Copper", "Silver", "Bronze", "Slate"
294
- ],
295
  label="Color Mood",
296
- value="Neutral"
 
297
  )
298
 
299
  # Row 2 - Surface Finishes
@@ -820,48 +796,48 @@ def update_prompt(room, style, colors, floor_t, floor_c, floor_p,
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 and style
824
  prompt_parts = [f"Design a {style} {room.lower()} with a {colors} color scheme"]
825
 
826
- # Add floor details only if type is not "Keep Existing"
827
- if floor_t and floor_t != "Keep Existing":
828
  floor_desc = floor_t
829
- if floor_c and floor_c != "Keep Existing":
830
  floor_desc += f" in {floor_c}"
831
- if floor_p and floor_p != "Keep Existing":
832
  floor_desc += f" with {floor_p} pattern"
833
  prompt_parts.append(f"featuring {floor_desc} flooring")
834
 
835
- # Add wall details only if type is not "Keep Existing"
836
- if wall_t and wall_t != "Keep Existing":
837
  wall_desc = wall_t
838
- if wall_c and wall_c != "Keep Existing":
839
  wall_desc += f" in {wall_c}"
840
- if wall_f and wall_f != "Keep Existing":
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 selected and not "Keep Existing" or "None"
845
  accessories = []
846
 
847
  # Art Print
848
- if art_en and art_col and art_col 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 and mirror_fr 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 and sconce_col 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 and shelf_col 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 and plants_type not in ["Keep Existing", "None"]:
865
  accessories.append(f"{plants_size} {plants_type}")
866
 
867
  # Only add accessories section if there are any accessories
 
257
  gr.Markdown("## 🏠 Basic Settings")
258
  with gr.Row():
259
  room_type = gr.Dropdown(
 
 
 
 
 
 
260
  label="Room Type",
261
+ choices=["None"] + ["Living Room", "Bedroom", "Dining Room", "Kitchen", "Bathroom", "Home Office", "Master Bedroom", "Guest Room", "Study Room", "Game Room", "Media Room", "Nursery", "Gym", "Library"],
262
+ value="None"
263
  )
264
  style_preset = gr.Dropdown(
 
 
 
 
 
 
 
 
 
 
265
  label="Design Style",
266
+ choices=["None"] + ["Modern", "Contemporary", "Minimalist", "Industrial", "Scandinavian", "Mid-Century Modern", "Traditional", "Transitional", "Farmhouse", "Rustic", "Bohemian", "Art Deco", "Coastal", "Mediterranean", "Japanese", "French Country", "Victorian", "Colonial", "Gothic", "Baroque", "Rococo", "Neoclassical", "Eclectic", "Zen", "Tropical", "Shabby Chic", "Hollywood Regency", "Southwestern", "Asian Fusion", "Retro"],
267
+ value="None"
268
  )
269
  color_scheme = gr.Dropdown(
 
 
 
 
 
 
 
 
 
 
 
270
  label="Color Mood",
271
+ choices=["None"] + ["Neutral", "Monochromatic", "Minimalist White", "Warm Gray", "Cool Gray", "Earth Tones", "Pastel", "Bold Primary", "Jewel Tones", "Black and White", "Navy and Gold", "Forest Green", "Desert Sand", "Ocean Blue", "Sunset Orange", "Deep Purple", "Emerald Green", "Ruby Red", "Sapphire Blue", "Golden Yellow", "Sage Green", "Dusty Rose", "Charcoal", "Cream", "Burgundy", "Teal", "Copper", "Silver", "Bronze", "Slate"],
272
+ value="None"
273
  )
274
 
275
  # Row 2 - Surface Finishes
 
796
  sconce_en, sconce_col, sconce_style,
797
  shelf_en, shelf_col, shelf_size,
798
  plants_en, plants_type, plants_size):
799
+ # Start with basic room, style, and color scheme (these should always be included as they have valid defaults)
800
  prompt_parts = [f"Design a {style} {room.lower()} with a {colors} color scheme"]
801
 
802
+ # Add floor details only if not "Keep Existing" or "None"
803
+ if floor_t not in ["Keep Existing", "None"]:
804
  floor_desc = floor_t
805
+ if floor_c not in ["Keep Existing", "None"]:
806
  floor_desc += f" in {floor_c}"
807
+ if floor_p not in ["Keep Existing", "None"]:
808
  floor_desc += f" with {floor_p} pattern"
809
  prompt_parts.append(f"featuring {floor_desc} flooring")
810
 
811
+ # Add wall details only if not "Keep Existing" or "None"
812
+ if wall_t not in ["Keep Existing", "None"]:
813
  wall_desc = wall_t
814
+ if wall_c not in ["Keep Existing", "None"]:
815
  wall_desc += f" in {wall_c}"
816
+ if wall_f not in ["Keep Existing", "None"]:
817
  wall_desc += f" with {wall_f} finish"
818
  prompt_parts.append(f"with {wall_desc} walls")
819
 
820
+ # Add accessories only if enabled AND properties are not "Keep Existing" or "None"
821
  accessories = []
822
 
823
  # Art Print
824
+ if art_en and art_col not in ["Keep Existing", "None"] and art_size not in ["Keep Existing", "None"]:
825
  accessories.append(f"{art_size} {art_col} Art Print")
826
 
827
  # Mirror
828
+ if mirror_en and mirror_fr not in ["Keep Existing", "None"] and mirror_size not in ["Keep Existing", "None"]:
829
  accessories.append(f"{mirror_size} Mirror with {mirror_fr} frame")
830
 
831
  # Wall Sconce
832
+ if sconce_en and sconce_col not in ["Keep Existing", "None"] and sconce_style not in ["Keep Existing", "None"]:
833
  accessories.append(f"{sconce_style} {sconce_col} Wall Sconce")
834
 
835
  # Floating Shelves
836
+ if shelf_en and shelf_col not in ["Keep Existing", "None"] and shelf_size not in ["Keep Existing", "None"]:
837
  accessories.append(f"{shelf_size} {shelf_col} Floating Shelves")
838
 
839
  # Wall Plants
840
+ if plants_en and plants_type not in ["Keep Existing", "None"] and plants_size not in ["Keep Existing", "None"]:
841
  accessories.append(f"{plants_size} {plants_type}")
842
 
843
  # Only add accessories section if there are any accessories