Spaces:
Runtime error
Runtime error
File size: 1,738 Bytes
44df93e afcda0c 44df93e afcda0c ef7ae97 44df93e 143c00f 44df93e ef7ae97 afcda0c 44df93e 887e763 44df93e afcda0c ef7ae97 afcda0c 44df93e 143c00f 44df93e afcda0c 143c00f afcda0c ef7ae97 afcda0c 44df93e 143c00f |
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 |
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
def dell(ix):
print("!!!!")
st.session_state.results.pop(ix)
def app():
st.title('AI-Generated Architecture')
st.subheader('Download your images or choose which images you would like to remove from your working set.')
d = datetime.datetime.now()
zipObj = zipfile.ZipFile('ai_architecture.zip', 'w')
deleteButtons = []
for ix,result in enumerate( st.session_state.results ):
with st.container():
col1,col2 = st.columns(2)
with col1:
t = st.image(result['image'])
with io.BytesIO() as output:
result['image'].save(output, format="JPEG")
contents = output.getvalue()
txt = str(ix+1)+") " + result['prompt']+" (temperature:"+ str(result['crazy']) + ", top k:" + str(result['k']) + ")"
zipObj.writestr(txt+".jpg", contents )
with col2:
if(len(st.session_state.results) > 1):
st.button("delete ", key=ix, on_click=dell, kwargs=dict(ix=ix) )
m = st.markdown("""
<hr />""", unsafe_allow_html=True)
zipObj.close()
st.download_button(
label="Download images as zip",
data=open('ai_architecture.zip', 'rb'),
file_name='ai_architecture '+d.strftime("%m-%d-%Y")+'.zip',
mime='application/zip'
)
|