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()