import collections from numpy.core.defchararray import lower import streamlit as st import numpy as np import pandas as pd from zipfile import ZipFile import io import os 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.') os.chdir(r"temp/") all_files = os.listdir() for f in all_files: os.remove(f) # create a ZipFile object zipObj = ZipFile('ai_architecture.zip', 'w') # Add multiple files to the zip for ix,file in enumerate( st.session_state.results ): file['image'].save("temp/"+str(ix)+".jpeg") zipObj.write("temp/"+str(ix)+".jpeg") zipObj.close() st.download_button( label="Download images as zip", data=open('ai_architecture.zip', 'rb'), file_name='ai_architecture.zip', mime='application/zip' ) deleteButtons = [] for ix,result in enumerate( st.session_state.results ): with st.container(): col1,col2 = st.columns(2) with col1: st.image(result['image']) with col2: st.button("delete ", key=ix, on_click=dell, kwargs=dict(ix=ix) ) m = st.markdown("""