Spaces:
Runtime error
Runtime error
Update page/generate.py
Browse files- page/generate.py +46 -24
page/generate.py
CHANGED
@@ -7,41 +7,42 @@ import streamlit as st
|
|
7 |
import pandas as pd
|
8 |
import numpy as np
|
9 |
import os, random, time
|
10 |
-
from utils import footer, generate, drawGrid
|
11 |
from PIL import Image
|
12 |
|
13 |
mode = "ai"
|
14 |
#mode = "dummy"
|
15 |
|
16 |
def app():
|
17 |
-
|
18 |
|
19 |
st.title('AI-Generated Architecture')
|
20 |
|
21 |
-
st.subheader('(beta v1.
|
22 |
|
23 |
-
st.text('This is a working beta version with bugs. Known issues are:\n-Some images will grey out when you change the input parameters')
|
24 |
|
25 |
-
st.subheader('Describe a building, interior, or other architecture you would like to see.')
|
26 |
|
27 |
#Modern architecture museum with black brick and large windows.
|
28 |
-
|
|
|
29 |
|
30 |
st.text("")
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
""")
|
40 |
|
41 |
st.text("")
|
42 |
|
43 |
crazy = st.slider('Temperature. This controls how "crazy" generated images are, where 0 is the least crazy.', 0.0, 1.0, 0.75)
|
44 |
-
k = st.slider('Top K. The higher the value, the higher quality the results tend to be at the cost of extra processing time.', 1, 10,
|
|
|
45 |
|
46 |
if( 'results' not in st.session_state ):
|
47 |
st.session_state.results = []
|
@@ -51,22 +52,29 @@ def app():
|
|
51 |
|
52 |
already = []
|
53 |
|
54 |
-
if startButton or hasattr(st.session_state, 'load_state'):
|
55 |
|
56 |
-
with st.spinner("Generating..."):
|
57 |
|
58 |
holder.empty()
|
59 |
|
60 |
-
nextButton = holder.button("finished generating images")
|
61 |
st.session_state.load_state = True
|
62 |
|
63 |
placeholder = st.empty()
|
64 |
second = st.empty()
|
65 |
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
|
69 |
-
|
|
|
|
|
|
|
|
|
70 |
|
71 |
with second.container():
|
72 |
drawGrid()
|
@@ -75,14 +83,28 @@ def app():
|
|
75 |
|
76 |
st.session_state.bar = placeholder.progress(0)
|
77 |
|
78 |
-
|
79 |
-
if(nextButton):
|
80 |
st.session_state.page = 1
|
81 |
break
|
82 |
|
83 |
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
|
|
|
|
86 |
|
87 |
|
88 |
st.session_state.bar = st.container()
|
|
|
7 |
import pandas as pd
|
8 |
import numpy as np
|
9 |
import os, random, time
|
10 |
+
from utils import footer, generate, drawGrid, generate2
|
11 |
from PIL import Image
|
12 |
|
13 |
mode = "ai"
|
14 |
#mode = "dummy"
|
15 |
|
16 |
def app():
|
17 |
+
global _prompt
|
18 |
|
19 |
st.title('AI-Generated Architecture')
|
20 |
|
21 |
+
#st.subheader('(beta v1.1)')
|
22 |
|
23 |
+
#st.text('This is a working beta version with bugs. Known issues are:\n-Some images will grey out when you change the input parameters')
|
24 |
|
25 |
+
st.subheader('Describe a building, interior, or other architecture you would like to see. You can change the prompt and input parameters on the fly.')
|
26 |
|
27 |
#Modern architecture museum with black brick and large windows.
|
28 |
+
print("Prompt: "+st.session_state.prompt)
|
29 |
+
prompt = st.text_input(label="",value=st.session_state.prompt)
|
30 |
|
31 |
st.text("")
|
32 |
|
33 |
+
#with st.expander("Having trouble thinking of something? Click here to view examples."):
|
34 |
+
# st.write("""
|
35 |
+
# • Modern architecture museum with black brick and large windows.\n
|
36 |
+
# • A prosaic, simple architecture.\n
|
37 |
+
# • An urban, post-modern architecture with concrete and steel.\n
|
38 |
+
# • A sleek urban interior design.
|
39 |
+
# """)
|
|
|
40 |
|
41 |
st.text("")
|
42 |
|
43 |
crazy = st.slider('Temperature. This controls how "crazy" generated images are, where 0 is the least crazy.', 0.0, 1.0, 0.75)
|
44 |
+
k = st.slider('Top K. The higher the value, the higher quality the results tend to be at the cost of extra processing time.', 1, 10, 5)
|
45 |
+
k = k*400
|
46 |
|
47 |
if( 'results' not in st.session_state ):
|
48 |
st.session_state.results = []
|
|
|
52 |
|
53 |
already = []
|
54 |
|
55 |
+
if startButton or hasattr(st.session_state, 'load_state') or st.session_state.prompt is not None:
|
56 |
|
57 |
+
with st.spinner("Generating..."):
|
58 |
|
59 |
holder.empty()
|
60 |
|
|
|
61 |
st.session_state.load_state = True
|
62 |
|
63 |
placeholder = st.empty()
|
64 |
second = st.empty()
|
65 |
|
66 |
+
nextButton = False
|
67 |
+
|
68 |
+
f = True
|
69 |
+
|
70 |
+
ii = 0
|
71 |
+
while len(st.session_state.results) <= 4*64:
|
72 |
|
73 |
+
ii += 1
|
74 |
+
|
75 |
+
if(f and len(st.session_state.results) > 0):
|
76 |
+
f = False
|
77 |
+
nextButton = holder.button("finished generating images")
|
78 |
|
79 |
with second.container():
|
80 |
drawGrid()
|
|
|
83 |
|
84 |
st.session_state.bar = placeholder.progress(0)
|
85 |
|
86 |
+
if(len(st.session_state.results) > 0 and nextButton):
|
|
|
87 |
st.session_state.page = 1
|
88 |
break
|
89 |
|
90 |
|
91 |
+
|
92 |
+
#if(ii % 2 == 1):
|
93 |
+
generate2(prompt,crazy,k)
|
94 |
+
#generate(prompt ,crazy,k)
|
95 |
+
|
96 |
+
|
97 |
+
if ii % 6 == 0:
|
98 |
+
_1 = ["A modern ","A post-modern ","An ultramodern ", "A classical ", "A parametric ", "A contemporary ", "A minimalist "]
|
99 |
+
_2 = ["museum architecture","home architecture","landscape architecture","interior design","structure architecture"]
|
100 |
+
_3 = [""," in the style of I.M. Pei"," in the style of Frank Gehry"," in the style of John Lautner"," in the style of Frank Lloyd Wright"]
|
101 |
+
_4 = [" photograph",", watercolor painting",", oil painting", ", digital art"]
|
102 |
+
|
103 |
+
prompt = str(random.choice(_1)+random.choice(_2)+random.choice(_3)+random.choice(_4))
|
104 |
+
print("swap")
|
105 |
|
106 |
+
crazy = random.random()*2
|
107 |
+
k = random.randrange(1,2500)
|
108 |
|
109 |
|
110 |
st.session_state.bar = st.container()
|