Spaces:
Running
Running
File size: 964 Bytes
0590b95 d55b56b 0590b95 d55b56b c1c018a d55b56b 1757fdb 136c114 1757fdb d55b56b c1c018a d55b56b 1757fdb d55b56b 1757fdb 0590b95 d55b56b |
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 |
import gradio as gr
from PIL import Image
from datetime import datetime
from ocr_engine import extract_weight
def process_image(image):
if image is None:
return "No image provided", None, None
weight = extract_weight(image)
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return f"{weight} grams", now, image
with gr.Blocks() as demo:
gr.Markdown("## 📷 Auto Weight Logger — OCR-Based Smart Scale Reader")
gr.Markdown("Upload an image or capture from webcam. The app will extract the weight using OCR.")
image_input = gr.Image(type="pil", label="📸 Upload or Capture Image (Webcam works in some browsers)")
btn = gr.Button("🚀 Detect Weight")
weight_out = gr.Textbox(label="Detected Weight")
time_out = gr.Textbox(label="Captured At (IST)")
snapshot_out = gr.Image(label="Snapshot")
btn.click(fn=process_image, inputs=image_input, outputs=[weight_out, time_out, snapshot_out])
demo.launch()
|