Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,25 +12,15 @@ def process_image(image):
|
|
12 |
|
13 |
with gr.Blocks() as demo:
|
14 |
gr.Markdown("## π· Auto Weight Logger β OCR-Based Smart Scale Reader")
|
15 |
-
gr.Markdown("Upload
|
16 |
|
17 |
-
|
18 |
-
camera_input = gr.Camera(label="πΈ Capture via Webcam", type="pil")
|
19 |
-
upload_input = gr.Image(label="π Upload Image", type="pil")
|
20 |
-
|
21 |
-
selected_image = gr.State()
|
22 |
-
|
23 |
-
def choose_latest_image(cam_img, upload_img):
|
24 |
-
return cam_img if cam_img is not None else upload_img
|
25 |
-
|
26 |
-
camera_input.change(fn=choose_latest_image, inputs=[camera_input, upload_input], outputs=selected_image)
|
27 |
-
upload_input.change(fn=choose_latest_image, inputs=[camera_input, upload_input], outputs=selected_image)
|
28 |
|
29 |
btn = gr.Button("π Detect Weight")
|
30 |
weight_out = gr.Textbox(label="Detected Weight")
|
31 |
time_out = gr.Textbox(label="Captured At (IST)")
|
32 |
-
|
33 |
|
34 |
-
btn.click(fn=process_image, inputs=
|
35 |
|
36 |
demo.launch()
|
|
|
12 |
|
13 |
with gr.Blocks() as demo:
|
14 |
gr.Markdown("## π· Auto Weight Logger β OCR-Based Smart Scale Reader")
|
15 |
+
gr.Markdown("Upload an image or capture from webcam. The app will extract the weight using OCR.")
|
16 |
|
17 |
+
image_input = gr.Image(type="pil", label="πΈ Upload or Capture Image (Webcam works in some browsers)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
btn = gr.Button("π Detect Weight")
|
20 |
weight_out = gr.Textbox(label="Detected Weight")
|
21 |
time_out = gr.Textbox(label="Captured At (IST)")
|
22 |
+
snapshot_out = gr.Image(label="Snapshot")
|
23 |
|
24 |
+
btn.click(fn=process_image, inputs=image_input, outputs=[weight_out, time_out, snapshot_out])
|
25 |
|
26 |
demo.launch()
|