Spaces:
Runtime error
Runtime error
File size: 3,338 Bytes
853793f |
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
import collections
from numpy.core.defchararray import lower
import streamlit as st
import numpy as np
import pandas as pd
import zipfile
import io
import os
from streamlit.elements.image import image_to_url
import gzip
import requests
from io import BytesIO
from PIL import Image, ImageDraw
import base64
import datetime
import random, os, time
import threading
#List of files to use for each image object, 40 images total
files = [None]*40
def randomFile(ix):
path = r"exampleImages"
dd = list(os.listdir(path))
random.shuffle(dd)
#Parse through each file in directory
for file in dd:
#If file is not in files list, use it for next image
if file not in files:
files[ix] = file
return "exampleImages/"+file
def gen(_p):
if(_p is not False):
st.session_state.prompt = _p
st.session_state.page = 0
return
_1 = ["A modern ","A post-modern ","A classical ", "A parametric ", "A contemporary ", "A minimalist "]
_2 = ["museum architecture","home architecture","landscape architecture","interior design","structural 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"]
st.session_state.prompt = str(random.choice(_1)+random.choice(_2)+random.choice(_3)+random.choice(_4))
st.session_state.page = 0
def app():
#Array of image objects
images = []
for i in range(30):
files.append( randomFile(i) )
placeholder = st.empty()
with placeholder.container():
columns = [col1, col2, col3, col4, col5] = st.columns(5)
ix = 0
for column in columns:
with column:
for i in range(2):
images.append( st.empty() )
with images[ix].container():
st.image("exampleImages/"+files[ix])
ix += 1
st.title('AI-Generated Architecture')
prompt = st.text_input(label="Describe the architecture you want to see",value="An oil painting of a modern architecture")
c1,c2,c3 = st.columns(3)
with c1:
if st.button("Generate Architecture"):
if prompt:
gen(prompt)
elif prompt == "":
gen(False)
return
with c2:
if st.button("Random Prompt"):
gen(False)
return
st.text("")
columns2 = [col1, col2, col3, col4, col5] = st.columns(5)
for column in columns2:
with column:
for i in range(4):
images.append( st.empty() )
with images[ix].container():
st.image("exampleImages/"+files[ix])
ix += 1
last = -1
while(True):
ch = random.randrange(30)
with images[ch].container():
st.image(randomFile(ch))
time.sleep(0.33)
#download_thread = threading.Thread(target=background, name="Downloader")
#download_thread.start()
|