EnYa32 commited on
Commit
41e8473
·
verified ·
1 Parent(s): 92f6d1f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +18 -1
src/streamlit_app.py CHANGED
@@ -94,4 +94,21 @@ st.subheader("3) (Optional) Upload an image and regenerate results.json + detect
94
  st.caption("If you upload an image, the app will run detection and overwrite results.json and detected.jpg in the app runtime.")
95
 
96
  uploaded_img = st.file_uploader("Upload image (jpg/png/webp)", type=["jpg", "jpeg", "png", "webp"], key="img_uploader")
97
- conf_th = st.slider("Confidence thresh_
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  st.caption("If you upload an image, the app will run detection and overwrite results.json and detected.jpg in the app runtime.")
95
 
96
  uploaded_img = st.file_uploader("Upload image (jpg/png/webp)", type=["jpg", "jpeg", "png", "webp"], key="img_uploader")
97
+ conf_th = st.slider("Confidence threshold", 0.10, 0.90, 0.25, 0.05)
98
+
99
+ if uploaded_img is not None:
100
+ with st.spinner("Detecting objects and saving results..."):
101
+ results, out_img, out_json = detect_and_save(
102
+ uploaded_img, out_json="results.json", out_img="detected.jpg", conf_th=conf_th
103
+ )
104
+ st.success("✅ Saved new detected.jpg and results.json")
105
+
106
+ st.metric("Cars", results["cars"])
107
+ st.metric("Trucks", results["trucks"])
108
+ show_detected_image(out_img)
109
+
110
+ with open(out_json, "rb") as f:
111
+ st.download_button("⬇️ Download new results.json", f, file_name="results.json")
112
+
113
+ with open(out_img, "rb") as f:
114
+ st.download_button("⬇️ Download new detected.jpg", f, file_name="detected.jpg")