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 pandas as pd
from PIL import Image
import numpy as np
from streamlit_drawable_canvas import st_canvas
import io
# Set page config
st.set_page_config(page_title="Virtual Interior Designer", layout="wide")
# Initialize session state
if "room_layout" not in st.session_state:
st.session_state.room_layout = None
if "furniture_list" not in st.session_state:
st.session_state.furniture_list = pd.DataFrame(columns=["Item", "Width", "Length", "Color"])
# Sample furniture database
FURNITURE_DATABASE = {
"Sofa": {"width": 200, "length": 90, "colors": ["Gray", "Brown", "Black", "Beige"]},
"Dining Table": {"width": 150, "length": 90, "colors": ["Wood", "White", "Black"]},
"Bed": {"width": 200, "length": 180, "colors": ["Brown", "White", "Black"]},
"Chair": {"width": 50, "length": 50, "colors": ["Wood", "White", "Black", "Gray"]},
"Coffee Table": {"width": 100, "length": 60, "colors": ["Wood", "Glass", "White"]},
}
def main():
st.title("Virtual Interior Designer 🏠")
st.write("""
Design and visualize your dream space before making any purchases!
Draw your room layout and experiment with different furniture arrangements.
""")
col1, col2 = st.columns([2, 1])
with col1:
st.subheader("Room Layout Canvas")
st.write("Draw your room layout or upload a floor plan")
# Canvas for room layout
canvas_result = st_canvas(
fill_color="rgba(255, 165, 0, 0.3)",
stroke_width=2,
stroke_color="#000000",
background_color="#ffffff",
height=400,
drawing_mode="freedraw",
key="canvas",
)
if canvas_result.image_data is not None:
st.session_state.room_layout = canvas_result.image_data
with col2:
st.subheader("Add Furniture")
# Furniture selection form
with st.form("furniture_form"):
furniture_type = st.selectbox("Select Furniture", list(FURNITURE_DATABASE.keys()))
selected_furniture = FURNITURE_DATABASE[furniture_type]
width = st.number_input("Width (cm)",
value=selected_furniture["width"],
min_value=10,
max_value=500)
length = st.number_input("Length (cm)",
value=selected_furniture["length"],
min_value=10,
max_value=500)
color = st.selectbox("Color", selected_furniture["colors"])
submit_button = st.form_submit_button("Add Furniture")
if submit_button:
new_furniture = pd.DataFrame({
"Item": [furniture_type],
"Width": [width],
"Length": [length],
"Color": [color]
})
st.session_state.furniture_list = pd.concat([st.session_state.furniture_list, new_furniture],
ignore_index=True)
# Display furniture list
st.subheader("Your Furniture List")
if not st.session_state.furniture_list.empty:
st.dataframe(st.session_state.furniture_list)
if st.button("Clear Furniture List"):
st.session_state.furniture_list = pd.DataFrame(columns=["Item", "Width", "Length", "Color"])
st.rerun()
else:
st.info("Add furniture items to see them listed here")
# Design Tips
with st.expander("Design Tips 💡"):
st.markdown("""
* Leave enough space between furniture pieces for comfortable movement
* Consider the room's natural light when placing furniture
* Create conversation areas in living spaces
* Don't block doorways or windows
* Consider traffic flow through the room
""")
# Cost Estimation
if not st.session_state.furniture_list.empty:
st.subheader("Estimated Cost Range")
total_pieces = len(st.session_state.furniture_list)
# Simple mock cost estimation
min_cost = sum([len(item) * 100 for item in st.session_state.furniture_list["Item"]])
max_cost = min_cost * 3
st.write(f"Estimated budget range: ${min_cost:,} - ${max_cost:,}")
# Save Design
if st.session_state.room_layout is not None and not st.session_state.furniture_list.empty:
if st.button("Save Design"):
st.success("Design saved successfully! (Demo purposes only)")
# Footer
st.markdown("---")
st.markdown("""
*This is a demo application. In a real implementation, you would have:*
* 3D visualization capabilities
* Real furniture catalog with prices
* AR visualization features
* More accurate measurements and scaling
* Real-time collaboration features
""")
if __name__ == "__main__":
main()
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?