David Fischinger
commited on
Commit
·
be1bd59
1
Parent(s):
d7d7f68
fixed problem for two different image types (PIL, uploaded_file)
Browse files
app.py
CHANGED
|
@@ -75,6 +75,18 @@ def start_evaluation(uploaded_file):
|
|
| 75 |
evaluate(reversed_image)
|
| 76 |
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
st.markdown(DESCRIPTION)
|
| 79 |
|
| 80 |
|
|
@@ -101,7 +113,7 @@ for idx, image_path in enumerate(image_paths):
|
|
| 101 |
st.image(gt_paths[idx], use_column_width=True, caption="Ground Truth")
|
| 102 |
|
| 103 |
if img is not None:
|
| 104 |
-
|
| 105 |
|
| 106 |
def reset_image_select():
|
| 107 |
img = None
|
|
@@ -110,6 +122,5 @@ def reset_image_select():
|
|
| 110 |
uploaded_file= None
|
| 111 |
uploaded_file = st.file_uploader("Please upload an image", type=["jpeg", "jpg", "png"], on_change=reset_image_select)
|
| 112 |
if (uploaded_file is not None) and (img is None):
|
| 113 |
-
|
| 114 |
-
start_evaluation(pil_img)
|
| 115 |
|
|
|
|
| 75 |
evaluate(reversed_image)
|
| 76 |
|
| 77 |
|
| 78 |
+
def start_evaluation_pil_img(pil_image):
|
| 79 |
+
# Convert the PIL image to a NumPy array
|
| 80 |
+
opencv_image = np.array(pil_image)
|
| 81 |
+
# Convert the image from RGB (PIL format) to BGR (OpenCV format)
|
| 82 |
+
opencv_image = cv2.cvtColor(opencv_image, cv2.COLOR_RGB2BGR)
|
| 83 |
+
# Reverse the color channels back to RGB for display in Streamlit
|
| 84 |
+
reversed_image = opencv_image[:, :, ::-1]
|
| 85 |
+
|
| 86 |
+
st.image(reversed_image, caption="Input Image")
|
| 87 |
+
evaluate(reversed_image)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
st.markdown(DESCRIPTION)
|
| 91 |
|
| 92 |
|
|
|
|
| 113 |
st.image(gt_paths[idx], use_column_width=True, caption="Ground Truth")
|
| 114 |
|
| 115 |
if img is not None:
|
| 116 |
+
start_evaluation_pil_img(img)
|
| 117 |
|
| 118 |
def reset_image_select():
|
| 119 |
img = None
|
|
|
|
| 122 |
uploaded_file= None
|
| 123 |
uploaded_file = st.file_uploader("Please upload an image", type=["jpeg", "jpg", "png"], on_change=reset_image_select)
|
| 124 |
if (uploaded_file is not None) and (img is None):
|
| 125 |
+
start_evaluation(uploaded_file)
|
|
|
|
| 126 |
|