-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_app.py
103 lines (72 loc) · 2.8 KB
/
streamlit_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import streamlit as st
from PIL import Image
import io
import Classes
import YOLO.detect as yolo
import pandas as pd
header = st.container()
app = st.container()
playground = st.container()
img_generator = Classes.Stable_Diff()
with header:
st.title('Ultimate Designs')
st.write('An OpenAI powered tool that helps users generate interior designs effortlessly.')
st.write('Redesign your room in different styles, Easy and Free!')
st.write('Here are some examples:')
col1, col2, col3 = st.columns(3)
show1 = Image.open('show1.png')
show2 = Image.open('show2.png')
show3 = Image.open('show3.png')
show3 = show3.resize((512, 512))
col1.image(show1)
col2.image(show2)
col3.image(show3)
with app:
st.header('Reimagine Room')
st.write('Select your desired prompts and uplaod a picture of your room')
style = st.selectbox('Which style: ', options=['Modern','Colorful'])
room = st.selectbox('Which room do you want the design for: ', options=['Living Room', 'Bedroom', 'Study Room'])
in_pic = st.file_uploader('Upload your room picture here')
if in_pic is not None:
bytes_data = in_pic.getvalue()
stream = io.BytesIO(bytes_data)
img = Image.open(stream)
prompt_editing = Classes.Prompt_Gen().presets(style, room)
st.write(prompt_editing)
pic, filename = img_generator.edit_image(img, prompt_editing)
st.image(pic)
print(filename)
pred, image, img_file = yolo.run(source = filename)
final_data = []
custom_db = pd.read_csv('custom_db.csv')
for item in pred:
temp_label = item['label']
if 'table' in temp_label:
temp_label = 'table'
print('table present')
if 'bed' in temp_label:
temp_label = 'bed'
print('bed present')
if 'chair' in temp_label:
temp_label = 'chair'
print('chair present')
if 'couch' in temp_label:
temp_label = 'couch'
print('couch present')
temp_params = [temp_label, style, room]
try:
temp_url = Classes.Dataset_Handler(custom_db).find_url(temp_params)
print(temp_url)
item['url'] = temp_url
st.write('Link to buy the '+str(item['label'])+ ' seen in the generated picture:')
st.write(str(item['url']))
except:
continue
with playground:
st.header('Stable Diffusion Playground')
st.write('Imagination is your only limit! Go wild!')
in_prompt = st.text_input('Prompt: ', '')
if in_prompt != '':
pic, filename = img_generator.txt_to_image(in_prompt)
st.image(pic)
st.caption('The team member names ')