Spaces:
Sleeping
Sleeping
File size: 910 Bytes
fb1a823 6608ec4 fb1a823 6608ec4 fb1a823 6608ec4 fb1a823 6608ec4 fb1a823 6608ec4 fb1a823 6608ec4 fb1a823 6608ec4 fb1a823 6608ec4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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") |