import collections from numpy.core.defchararray import lower import streamlit as st import numpy as np import pandas as pd import streamlit as st import pandas as pd import numpy as np import os, random, time from utils import footer, generate, drawGrid, generate2 from PIL import Image mode = "ai" #mode = "dummy" def app(): global _prompt st.title('AI-Generated Architecture') #st.subheader('(beta v1.1)') #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') 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.') #Modern architecture museum with black brick and large windows. print("Prompt: "+st.session_state.prompt) prompt = st.text_input(label="",value=st.session_state.prompt) st.text("") #with st.expander("Having trouble thinking of something? Click here to view examples."): # st.write(""" # • Modern architecture museum with black brick and large windows.\n # • A prosaic, simple architecture.\n # • An urban, post-modern architecture with concrete and steel.\n # • A sleek urban interior design. # """) st.text("") crazy = st.slider('Temperature. This controls how "crazy" generated images are, where 0 is the least crazy.', 0.0, 1.0, 0.75) 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) k = k*400 if( 'results' not in st.session_state ): st.session_state.results = [] holder = st.empty() startButton = holder.button("Start") already = [] if startButton or hasattr(st.session_state, 'load_state') or st.session_state.prompt is not None: with st.spinner("Generating..."): holder.empty() st.session_state.load_state = True placeholder = st.empty() second = st.empty() nextButton = False f = True ii = 0 while len(st.session_state.results) <= 4*64: ii += 1 if(f and len(st.session_state.results) > 0): f = False nextButton = holder.button("finished generating images") with second.container(): drawGrid() with placeholder.container(): st.session_state.bar = placeholder.progress(0) if(len(st.session_state.results) > 0 and nextButton): st.session_state.page = 1 break #if(ii % 2 == 1): generate2(prompt,crazy,k) #generate(prompt ,crazy,k) if ii % 6 == 0: _1 = ["A modern ","A post-modern ","An ultramodern ", "A classical ", "A parametric ", "A contemporary ", "A minimalist "] _2 = ["museum architecture","home architecture","landscape architecture","interior design","structure architecture"] _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"] _4 = [" photograph",", watercolor painting",", oil painting", ", digital art"] prompt = str(random.choice(_1)+random.choice(_2)+random.choice(_3)+random.choice(_4)) print("swap") crazy = random.random()*2 k = random.randrange(1,2500) st.session_state.bar = st.container()