dal4933 commited on
Commit
ff3b583
·
verified ·
1 Parent(s): 4336a2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -52,15 +52,21 @@ def scan_barcode(image):
52
  return {"status": "error", "message": f"Processing error: {str(e)}"}
53
 
54
  # Create Gradio interface
55
- iface = gr.Interface(
56
- fn=scan_barcode,
57
- inputs=gr.Image(label="Barcode Image", type="numpy"),
58
- outputs=gr.JSON(label="Scan Result"),
59
- title="📦 Barcode Scanner API",
60
- description="Upload an image to scan barcode",
61
- flagging_mode="never", # Updated parameter
62
- api_name="scan"
63
- )
 
 
 
 
 
 
64
 
65
  # Launch the application
66
  if __name__ == "__main__":
 
52
  return {"status": "error", "message": f"Processing error: {str(e)}"}
53
 
54
  # Create Gradio interface
55
+ with gr.Blocks() as iface:
56
+ gr.Markdown("# 📦 Barcode Scanner API")
57
+ gr.Markdown("Upload an image to scan barcode")
58
+
59
+ with gr.Row():
60
+ image_input = gr.Image(label="Barcode Image", type="numpy")
61
+ json_output = gr.JSON(label="Scan Result")
62
+
63
+ # Create the API endpoint
64
+ image_input.change(
65
+ fn=scan_barcode,
66
+ inputs=image_input,
67
+ outputs=json_output,
68
+ api_name="scan"
69
+ )
70
 
71
  # Launch the application
72
  if __name__ == "__main__":