Spaces:
Runtime error
Runtime error
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 contemporary ", "A minimalist "] | |
_2 = ["museum architecture","home architecture","interior design"] | |
_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="") | |
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() | |