File size: 1,382 Bytes
44df93e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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("""
            <hr />""", unsafe_allow_html=True)