File size: 1,266 Bytes
833d304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import os

def save_uploaded_files(files, folder_path):
    # Create the folder if it doesn't exist
    if not os.path.exists(folder_path):
        os.makedirs(folder_path)

    saved_file_paths = []
    for file in files:
        # Save each uploaded file to the folder
        file_path = os.path.join(folder_path, file.name)
        with open(file_path, "wb") as f:
            f.write(file.getbuffer())
        saved_file_paths.append(file_path)

    return saved_file_paths

# Streamlit app
def show_predict_page():
    st.title("Multi-image Uploader")
    
    # File uploader
    uploaded_files = st.file_uploader("Upload four images", type=["jpg", "jpeg", "png"], accept_multiple_files=True, key="file_uploader")
    
    if uploaded_files is not None:
        # Save the uploaded files to a folder
        folder_path = "image_folder"
        saved_file_paths = save_uploaded_files(uploaded_files, folder_path)
        
        # Display the uploaded images
        for file_path in saved_file_paths:
            st.image(file_path, caption="Uploaded Image", use_column_width=True)
        
        # Display the file paths
        st.write("Files saved at:")
        for file_path in saved_file_paths:
            st.write(file_path)