Build a ai powered virtual furniture placement and interior decor app that helps in designing and furnishing home before buying and trying out
To upload files, please first save the app
import streamlit as st
import os
from PIL import Image
import numpy as np
import pandas as pd
# Set page config
st.set_page_config(page_title="Virtual Interior Designer", layout="wide")
# Initialize session state
if 'room_image' not in st.session_state:
st.session_state.room_image = None
if 'furniture_items' not in st.session_state:
st.session_state.furniture_items = []
if 'current_design' not in st.session_state:
st.session_state.current_design = None
# Load furniture database
@st.cache_data
def load_furniture_data():
furniture_data = {
'Item': ['Sofa', 'Coffee Table', 'Dining Table', 'Chair', 'Bed', 'Bookshelf', 'Desk'],
'Style': ['Modern', 'Contemporary', 'Traditional', 'Modern', 'Contemporary', 'Traditional', 'Modern'],
'Color': ['Gray', 'Brown', 'White', 'Black', 'Beige', 'Walnut', 'White'],
'Price': [999, 299, 599, 199, 899, 399, 349],
'Dimensions': ['84"x36"x32"', '48"x24"x18"', '72"x36"x30"', '20"x20"x32"', '80"x60"x24"', '72"x36"x14"', '60"x30"x29"']
}
return pd.DataFrame(furniture_data)
# Main UI
st.title("🏠 Virtual Interior Designer")
st.write("Design and visualize your dream space before making any purchases!")
# Sidebar for controls
st.sidebar.header("Room Setup")
# Room type selection
room_type = st.sidebar.selectbox(
"Select Room Type",
["Living Room", "Bedroom", "Dining Room", "Home Office"]
)
# Upload room image
room_image = st.sidebar.file_uploader("Upload Room Image", type=['jpg', 'png'])
if room_image:
st.session_state.room_image = Image.open(room_image)
# Load furniture database
furniture_db = load_furniture_data()
# Main content area
col1, col2 = st.columns([2, 1])
with col1:
st.subheader("Room Preview")
if st.session_state.room_image:
st.image(st.session_state.room_image, use_column_width=True)
else:
st.info("Please upload a room image to start designing")
with col2:
st.subheader("Furniture Selection")
# Filter options
style_filter = st.selectbox("Style", ["All"] + list(furniture_db['Style'].unique()))
price_range = st.slider("Price Range", 0, 2000, (0, 2000))
# Filter furniture database
filtered_furniture = furniture_db
if style_filter != "All":
filtered_furniture = filtered_furniture[filtered_furniture['Style'] == style_filter]
filtered_furniture = filtered_furniture[
(filtered_furniture['Price'] >= price_range[0]) &
(filtered_furniture['Price'] <= price_range[1])
]
# Display filtered furniture
st.table(filtered_furniture)
# Design recommendations
st.subheader("AI Design Recommendations")
if room_type and st.session_state.room_image:
st.write("Based on your room type and style preferences, here are some suggestions:")
recommendations = {
"Living Room": [
"Consider a neutral-colored sofa as the focal point",
"Add a coffee table that matches your style preference",
"Include accent chairs for additional seating",
"Layer lighting with floor and table lamps"
],
"Bedroom": [
"Start with a bed that fits the room scale",
"Add bedside tables for symmetry",
"Consider a dresser for storage",
"Include soft lighting options"
],
"Dining Room": [
"Choose a dining table that seats your typical gathering size",
"Select comfortable dining chairs",
"Add a sideboard for storage and serving",
"Consider a statement lighting fixture"
],
"Home Office": [
"Prioritize a comfortable and ergonomic desk setup",
"Choose storage solutions like bookshelves or filing cabinets",
"Ensure proper task lighting",
"Add a comfortable office chair"
]
}
for rec in recommendations[room_type]:
st.write(f"• {rec}")
# Cost estimation
st.subheader("Budget Planning")
selected_items = st.multiselect(
"Select items for your room",
furniture_db['Item'].tolist()
)
if selected_items:
total_cost = furniture_db[furniture_db['Item'].isin(selected_items)]['Price'].sum()
st.write(f"Estimated Total Cost: ${total_cost:,.2f}")
# Help section
with st.expander("How to Use This Tool"):
st.write("""
1. Upload a photo of your room
2. Select the room type and style preferences
3. Browse through our furniture catalog
4. Use the filters to narrow down your options
5. View AI-powered design recommendations
6. Plan your budget with the cost estimator
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?