VTS / core /ui.py
thanhhiepvos's picture
Upload 10 files
28037b0 verified
import streamlit as st
from PIL import Image
import os
def show_choosing_pic_bar(images, img_folder):
st.sidebar.header("πŸ“‚ Select an Image")
col1, col2 = st.sidebar.columns(2)
selected_img = None
for i, img_name in enumerate(images):
img_path = os.path.join(img_folder, img_name)
image = Image.open(img_path).resize((100, 100))
col = col1 if i % 2 == 0 else col2
if col.button("Select", key=img_name):
st.session_state.selected_image = img_name
col.image(image, use_container_width = True)
#st.sidebar.image(image)
col.caption(img_name)
def show_right_sidebar(col):
# Set defaults if not present
if "confidence" not in st.session_state:
st.session_state.confidence = 0.25
if "iou" not in st.session_state:
st.session_state.iou = 0.7
if "show_confidence" not in st.session_state:
st.session_state.show_confidence = False # Set default to False
with col:
st.markdown("### βš™οΈ Hyperparameters", unsafe_allow_html=True)
# --- Confidence ---
st.session_state.confidence = st.number_input(
"Confidence Threshold", min_value=0.0, max_value=1.0,
step=0.01, value=st.session_state.confidence,
format="%.2f"
)
st.caption("Confidence score for label in predicted bounding box.")
st.divider()
# --- IOU ---
st.session_state.iou = st.number_input(
"IOU Threshold", min_value=0.0, max_value=1.0,
step=0.01, value=st.session_state.iou,
format="%.2f"
)
st.caption("Lower values result in fewer detections by eliminating overlapping boxes, useful for reducing duplicates.")
st.markdown("---")
st.header("πŸ“Š Display Options")
# --- Show Confidence Checkbox ---
st.session_state.show_confidence = st.checkbox(
"Show Confidence", value=st.session_state.show_confidence
)
return st.session_state.confidence, st.session_state.iou, st.session_state.show_confidence