ai_architecture / page /reduce.py
JMalott's picture
Update page/reduce.py
afcda0c
raw
history blame
1.55 kB
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
def dell(ix):
print("!!!!")
st.session_state.results.pop(ix)
def app():
st.title('AI-Generated Architecture')
st.subheader('Choose which images you would like to remove from your working set.')
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 = result['prompt']+" (temperature:"+ str(result['crazy']) + ", top k:" + str(result['k']) + ")"
zipObj.writestr(txt+".jpg", contents )
with col2:
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.zip',
mime='application/zip'
)