Build a ai powered virtual furniture placement and interior decor app
To upload files, please first save the app
import streamlit as st
import os
from PIL import Image
import numpy as np
st.set_page_config(page_title="AI Interior Decor Assistant", 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 "messages" not in st.session_state:
st.session_state.messages = []
# App header
st.title("🏠 AI Interior Decor Assistant")
st.write("Upload a room photo and get AI-powered furniture placement and decor suggestions!")
# Sidebar for room preferences
with st.sidebar:
st.header("Room Preferences")
style = st.selectbox(
"Interior Style",
["Modern", "Minimalist", "Traditional", "Industrial", "Scandinavian", "Bohemian"]
)
budget = st.slider(
"Budget Range ($)",
min_value=1000,
max_value=50000,
value=(5000, 15000),
step=1000
)
color_scheme = st.multiselect(
"Color Scheme",
["Neutral", "Warm", "Cool", "Bold", "Pastel"],
default=["Neutral"]
)
# Main content area
col1, col2 = st.columns(2)
with col1:
st.subheader("Room Upload")
uploaded_file = st.file_uploader("Upload a photo of your room", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
image = Image.open(uploaded_file)
st.session_state.room_image = image
st.image(image, caption="Your Room", use_column_width=True)
with col2:
st.subheader("AI Suggestions")
if st.session_state.room_image is not None:
# Chat interface for AI suggestions
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.write(message["content"])
if prompt := st.chat_input("Ask for specific suggestions or advice"):
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
with st.chat_message("user"):
st.write(prompt)
# Simulate AI response
ai_response = generate_ai_response(prompt, style, budget, color_scheme)
with st.chat_message("assistant"):
st.write(ai_response)
st.session_state.messages.append({"role": "assistant", "content": ai_response})
else:
st.info("Please upload a room photo to get AI suggestions")
# Function to generate AI responses (simulated)
def generate_ai_response(prompt, style, budget, color_scheme):
responses = [
f"Based on your {style} style preference and budget of ${budget[0]}-${budget[1]}, I suggest:",
"1. Consider adding a modern sectional sofa in neutral tones",
"2. A minimalist coffee table would complement the space well",
f"3. For the {', '.join(color_scheme)} color scheme, add accent pieces in these tones",
"4. Layer lighting with floor and table lamps",
"5. Add texture with area rugs and throw pillows"
]
return "\n".join(responses)
# Footer with additional information
st.markdown("---")
st.markdown("""
### How to use this app:
1. Upload a photo of your room
2. Set your preferences in the sidebar
3. Chat with the AI assistant for personalized suggestions
4. Get real-time visualization of furniture placement
""")
# Additional features section
if st.session_state.room_image is not None:
st.subheader("Additional Features")
tabs = st.tabs(["3D Preview", "Shopping List", "Save Design"])
with tabs[0]:
st.write("3D preview feature coming soon!")
with tabs[1]:
st.write("Recommended Items:")
example_items = {
"Sofa": "$1,299",
"Coffee Table": "$399",
"Area Rug": "$249",
"Floor Lamp": "$159",
"Accent Chair": "$599"
}
st.table(example_items)
with tabs[2]:
if st.button("Save Current Design"):
st.success("Design saved successfully!")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?