Spaces:
Build error
Build error
Commit ·
ca09978
1
Parent(s): e2e5eda
Fix depth image
Browse files
streamlit_apps/app_utils/image_inference.py
CHANGED
|
@@ -22,14 +22,19 @@ def image_inference(
|
|
| 22 |
image: Image = None
|
| 23 |
# depth: Image = None
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
with col1:
|
| 26 |
img_file_buffer = st.file_uploader(
|
| 27 |
-
"Upload an RGB image",
|
|
|
|
|
|
|
|
|
|
| 28 |
)
|
| 29 |
if img_file_buffer is not None:
|
| 30 |
image = Image.open(img_file_buffer).convert("RGB")
|
| 31 |
st.image(image, caption="RGB")
|
| 32 |
-
st.session_state.depth = None
|
| 33 |
|
| 34 |
with col2:
|
| 35 |
depth_file_buffer = st.file_uploader(
|
|
@@ -55,7 +60,7 @@ def image_inference(
|
|
| 55 |
disabled=img_file_buffer is None,
|
| 56 |
)
|
| 57 |
if is_predict:
|
| 58 |
-
with st.spinner("Processing..."):
|
| 59 |
start_time = time.time()
|
| 60 |
pred_depth, pred_sods, pred_sms = base_inference(
|
| 61 |
depth_model,
|
|
|
|
| 22 |
image: Image = None
|
| 23 |
# depth: Image = None
|
| 24 |
|
| 25 |
+
def file_uploader_on_change():
|
| 26 |
+
st.session_state.depth = None
|
| 27 |
+
|
| 28 |
with col1:
|
| 29 |
img_file_buffer = st.file_uploader(
|
| 30 |
+
"Upload an RGB image",
|
| 31 |
+
key="img_file_buffer",
|
| 32 |
+
type=["png", "jpg", "jpeg"],
|
| 33 |
+
on_change=file_uploader_on_change,
|
| 34 |
)
|
| 35 |
if img_file_buffer is not None:
|
| 36 |
image = Image.open(img_file_buffer).convert("RGB")
|
| 37 |
st.image(image, caption="RGB")
|
|
|
|
| 38 |
|
| 39 |
with col2:
|
| 40 |
depth_file_buffer = st.file_uploader(
|
|
|
|
| 60 |
disabled=img_file_buffer is None,
|
| 61 |
)
|
| 62 |
if is_predict:
|
| 63 |
+
with st.spinner("Processing... (it takes about 1-2 minutes)"):
|
| 64 |
start_time = time.time()
|
| 65 |
pred_depth, pred_sods, pred_sms = base_inference(
|
| 66 |
depth_model,
|