File size: 533 Bytes
0590b95
d55b56b
a8e065f
 
0590b95
d55b56b
a8e065f
 
 
 
 
 
 
 
 
 
 
 
3a4eb5d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from ocr_engine import extract_weight
from PIL import Image
import tempfile

def process_image(image):
    with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as f:
        image.save(f.name)
        result = extract_weight(f.name)
    return result

demo = gr.Interface(
    fn=process_image,
    inputs=gr.Image(type="pil"),
    outputs="text",
    title="Auto Weight Detector",
    description="Upload an image of a digital balance showing weight in g or kg (e.g. 52.25 g, 75.8 kg)"
)

demo.launch()