Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 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__":
|