awacke1 commited on
Commit
e028124
·
1 Parent(s): 985be42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -20
app.py CHANGED
@@ -1,28 +1,49 @@
 
1
  import streamlit as st
2
- import pandas as pd
3
- from io import StringIO
4
- from PIL import Image
5
- import graphviz as gv
 
 
 
6
 
7
- uploaded_files = st.file_uploader("Choose an image file", accept_multiple_files=True, type=["jpg", "jpeg", "png"])
8
- images = []
9
 
10
- for uploaded_file in uploaded_files:
11
- # To read file as bytes:
12
- bytes_data = uploaded_file.getvalue()
13
 
14
- # To convert to a PIL image:
15
- image = Image.open(uploaded_file)
16
- images.append(image)
 
17
 
18
- # Create the Graphviz model using the uploaded images
19
- dot = gv.Digraph()
20
- for i, image in enumerate(images):
21
- dot.node(str(i), image=image)
22
 
23
- for i in range(len(images) - 1):
24
- dot.edge(str(i), str(i+1))
25
 
26
- # Render the Graphviz model using the Streamlit framework
27
- st.graphviz_chart(dot.source)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
 
 
 
 
 
1
+
2
  import streamlit as st
3
+ from io import BytesIO
4
+
5
+ # Create a sidebar to display the list of uploaded files
6
+ uploaded_files = st.sidebar.empty()
7
+
8
+ # Use the file uploader to accept multiple files
9
+ files = st.file_uploader("Choose files", accept_multiple_files=True)
10
 
11
+ # Create a div to display the uploaded files
12
+ div = st.empty()
13
 
14
+ # Initialize a list to store the uploaded files
15
+ file_list = []
 
16
 
17
+ # Loop through the uploaded files and add them to the file list
18
+ for file in files:
19
+ # Read the file as bytes
20
+ bytes_data = file.read()
21
 
22
+ # Add the file to the file list
23
+ file_list.append(bytes_data)
 
 
24
 
25
+ # Update the sidebar to display the list of uploaded files
26
+ uploaded_files.write([file.name for file in files])
27
 
28
+ # Use HTML and CSS to style the div and move it around the screen
29
+ div.markdown("""
30
+ <style>
31
+ .sticky {
32
+ position: fixed;
33
+ bottom: 20px;
34
+ right: 20px;
35
+ padding: 10px;
36
+ background-color: #f5f5f5;
37
+ border: 1px solid #d3d3d3;
38
+ border-radius: 4px;
39
+ text-align: center;
40
+ font-size: 18px;
41
+ box-shadow: 2px 2px #888888;
42
+ }
43
+ </style>
44
+ """, unsafe_allow_html=True)
45
 
46
+ # Add the uploaded files to the div and make it move around the screen
47
+ if file_list:
48
+ for file in file_list:
49
+ div.markdown(f'<div class="sticky">{file}</div>', unsafe_allow_html=True)