Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -371,31 +371,29 @@ def start_image_search(image, text):
|
|
| 371 |
return images, description
|
| 372 |
|
| 373 |
def generate_qr_code(filename):
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
except Exception as e:
|
| 398 |
-
return f"Error: {e}"
|
| 399 |
|
| 400 |
with gr.Blocks() as demo:
|
| 401 |
|
|
|
|
| 371 |
return images, description
|
| 372 |
|
| 373 |
def generate_qr_code(filename):
|
| 374 |
+
# Read the content of the file
|
| 375 |
+
with open(filename, 'rb') as file:
|
| 376 |
+
file_content = file.read()
|
| 377 |
+
|
| 378 |
+
# Generate QR code
|
| 379 |
+
qr = qrcode.QRCode(
|
| 380 |
+
version=1,
|
| 381 |
+
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
| 382 |
+
box_size=10,
|
| 383 |
+
border=4,
|
| 384 |
+
)
|
| 385 |
+
qr.add_data(file_content)
|
| 386 |
+
qr.make(fit=True)
|
| 387 |
+
|
| 388 |
+
img_qr = qr.make_image(fill_color="black", back_color="white")
|
| 389 |
+
|
| 390 |
+
# Convert PIL Image to bytes for Gradio output
|
| 391 |
+
img_byte_arr = io.BytesIO()
|
| 392 |
+
img_qr.save(img_byte_arr, format='PNG')
|
| 393 |
+
img_byte_arr = img_byte_arr.getvalue()
|
| 394 |
+
|
| 395 |
+
return img_byte_arr
|
| 396 |
+
|
|
|
|
|
|
|
| 397 |
|
| 398 |
with gr.Blocks() as demo:
|
| 399 |
|