Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,11 +13,15 @@ def scan_qr_code(image):
|
|
13 |
Scan QR code from the uploaded image.
|
14 |
|
15 |
Args:
|
16 |
-
image (PIL.Image.Image): The uploaded image.
|
17 |
|
18 |
Returns:
|
19 |
str: The decoded QR code data with a descriptive message.
|
20 |
"""
|
|
|
|
|
|
|
|
|
21 |
# Convert PIL image to OpenCV format
|
22 |
open_cv_image = np.array(image)
|
23 |
open_cv_image = open_cv_image[:, :, ::-1].copy()
|
@@ -33,7 +37,7 @@ def scan_qr_code(image):
|
|
33 |
# Define the Gradio interface
|
34 |
iface = gr.Interface(
|
35 |
fn=scan_qr_code,
|
36 |
-
inputs=gr.Image(type="
|
37 |
outputs=gr.Textbox(),
|
38 |
title="QR Code Scanner",
|
39 |
description="Upload an image containing a QR code to decode it."
|
|
|
13 |
Scan QR code from the uploaded image.
|
14 |
|
15 |
Args:
|
16 |
+
image (PIL.Image.Image or str): The uploaded image or file path.
|
17 |
|
18 |
Returns:
|
19 |
str: The decoded QR code data with a descriptive message.
|
20 |
"""
|
21 |
+
# Convert file path to PIL image if necessary
|
22 |
+
if isinstance(image, str):
|
23 |
+
image = Image.open(image)
|
24 |
+
|
25 |
# Convert PIL image to OpenCV format
|
26 |
open_cv_image = np.array(image)
|
27 |
open_cv_image = open_cv_image[:, :, ::-1].copy()
|
|
|
37 |
# Define the Gradio interface
|
38 |
iface = gr.Interface(
|
39 |
fn=scan_qr_code,
|
40 |
+
inputs=gr.Image(type="filepath"),
|
41 |
outputs=gr.Textbox(),
|
42 |
title="QR Code Scanner",
|
43 |
description="Upload an image containing a QR code to decode it."
|