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("""