Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,28 @@
|
|
1 |
import streamlit as st
|
2 |
from io import BytesIO
|
|
|
|
|
|
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# Create a sidebar to display the list of uploaded files
|
5 |
uploaded_files = st.sidebar.empty()
|
6 |
|
|
|
1 |
import streamlit as st
|
2 |
from io import BytesIO
|
3 |
+
import imageio.v3 as iio
|
4 |
+
import cv2
|
5 |
+
import os
|
6 |
|
7 |
+
def get_image_path(img):
|
8 |
+
# Create a directory and save the uploaded image.
|
9 |
+
file_path = f"data/uploadedImages/{img.name}"
|
10 |
+
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
11 |
+
with open(file_path, "wb") as img_file:
|
12 |
+
img_file.write(img.getbuffer())
|
13 |
+
return file_path
|
14 |
+
|
15 |
+
uploaded_file = st.file_uploader("**Upload a Chest X-Ray Image**", type= ['png', 'jpg'] )
|
16 |
+
if uploaded_file is not None:
|
17 |
+
# Get actual image file
|
18 |
+
bytes_data = get_image_path(uploaded_file)
|
19 |
+
st.image(bytes_data)
|
20 |
+
# ReSize
|
21 |
+
item = cv2.resize(bytes_data,dsize=(224,224), interpolation=cv2.INTER_CUBIC)
|
22 |
+
# ReScale Values
|
23 |
+
item = item / 255
|
24 |
+
|
25 |
+
|
26 |
# Create a sidebar to display the list of uploaded files
|
27 |
uploaded_files = st.sidebar.empty()
|
28 |
|