Sanjayraju30 commited on
Commit
c41b38b
Β·
verified Β·
1 Parent(s): de0beca

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -9
src/streamlit_app.py CHANGED
@@ -1,7 +1,6 @@
1
  import streamlit as st
2
- import cv2
3
- import tempfile
4
- from ocr_engine import extract_weight
5
 
6
  st.set_page_config(page_title="Auto Weight Logger", layout="centered")
7
  st.title("βš–οΈ Auto Weight Logger")
@@ -9,9 +8,8 @@ st.title("βš–οΈ Auto Weight Logger")
9
  img_data = st.camera_input("πŸ“· Capture the weight display")
10
 
11
  if img_data:
12
- with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as f:
13
- f.write(img_data.getvalue())
14
- f.flush()
15
- weight = extract_weight(f.name)
16
- st.image(f.name, caption="πŸ“Έ Snapshot")
17
- st.success(f"βœ… Detected Weight: " + str(weight) + " g")
 
1
  import streamlit as st
2
+ from PIL import Image
3
+ from ocr_engine import extract_weight_from_image
 
4
 
5
  st.set_page_config(page_title="Auto Weight Logger", layout="centered")
6
  st.title("βš–οΈ Auto Weight Logger")
 
8
  img_data = st.camera_input("πŸ“· Capture the weight display")
9
 
10
  if img_data:
11
+ image = Image.open(img_data)
12
+ st.image(image, caption="πŸ“Έ Snapshot", use_column_width=True)
13
+ with st.spinner("Extracting weight..."):
14
+ weight = extract_weight_from_image(image)
15
+ st.success(f"βœ… Detected Weight: {weight} g")