File size: 2,304 Bytes
1dc4501
e028124
b056b61
 
 
e028124
b056b61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e028124
 
 
 
 
fea62a9
e028124
 
fea62a9
e028124
 
fea62a9
e028124
 
 
 
fea62a9
e028124
 
fea62a9
e028124
 
fea62a9
e028124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
985be42
416bd1d
e028124
 
cbe67dc
b51c9ee
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
60
61
62
63
64
65
66
67
68
69
70
71
72
import streamlit as st
from io import BytesIO
import imageio.v3 as iio
import cv2
import os

def get_image_path(img):
    # Create a directory and save the uploaded image.
    file_path = f"data/uploadedImages/{img.name}"
    os.makedirs(os.path.dirname(file_path), exist_ok=True)
    with open(file_path, "wb") as img_file:
        img_file.write(img.getbuffer())
    return file_path

uploaded_file = st.file_uploader("**Upload a Chest X-Ray Image**", type= ['png', 'jpg'] )
if uploaded_file is not None:
    # Get actual image file
    bytes_data = get_image_path(uploaded_file)
    st.image(bytes_data)
    # ReSize
    item = cv2.resize(bytes_data,dsize=(224,224), interpolation=cv2.INTER_CUBIC)
    # ReScale Values
    item = item / 255

    
# Create a sidebar to display the list of uploaded files
uploaded_files = st.sidebar.empty()

# Use the file uploader to accept multiple files
files = st.file_uploader("Choose files", accept_multiple_files=True)

# Create a div to display the uploaded files
div = st.empty()

# Initialize a list to store the uploaded files
file_list = []

# Loop through the uploaded files and add them to the file list
for file in files:
    # Read the file as bytes
    bytes_data = file.read()

    # Add the file to the file list
    file_list.append(bytes_data)

    # Update the sidebar to display the list of uploaded files
    uploaded_files.write([file.name for file in files])

# Use HTML and CSS to style the div and move it around the screen
div.markdown("""
    <style>
        .sticky {
            position: fixed;
            bottom: 20px;
            right: 20px;
            padding: 10px;
            background-color: #f5f5f5;
            border: 1px solid #d3d3d3;
            border-radius: 4px;
            text-align: center;
            font-size: 18px;
            box-shadow: 2px 2px #888888;
        }
    </style>
""", unsafe_allow_html=True)

# Add the uploaded files to the div as an anchor tag with an image that opens in a new tab
if file_list:
    for file in file_list:
        url = "https://huggingface.co/spaces/awacke1/CardCrafter-CraftCustomCards"  # Replace with the URL to open when the image is clicked
        div.markdown(f'<a href="{url}" target="_blank"><img src="{file.name}" class="sticky"></a>', unsafe_allow_html=True)