Auto-weight-logger / src /streamlit_app.py
Sanjayraju30's picture
Update src/streamlit_app.py
6608ec4 verified
raw
history blame
910 Bytes
import streamlit as st
import os
from PIL import Image
from ocr_engine import extract_weight_from_image
Install Tesseract runtime in Hugging Face Space
os.system("apt update && apt install -y tesseract-ocr")
st.set_page_config(page_title="βš–οΈ Auto Weight Logger", layout="centered")
st.title("πŸ“· Auto Weight Logger")
st.write("Capture the weight display using your camera or upload an image")
Option 1: Capture image from webcam
image_file = st.camera_input("Take a photo")
Option 2: Upload image from local machine
if image_file is None:
image_file = st.file_uploader("Or upload an image", type=["jpg", "jpeg", "png"])
if image_file is not None:
image = Image.open(image_file)
st.image(image, caption="Uploaded Image", use_column_width=True)
python
Copy
Edit
with st.spinner("πŸ” Extracting weight..."):
result = extract_weight_from_image(image)
st.success(f"βœ… Detected Weight: {result} g")