Pash1986 commited on
Commit
4cdc26f
1 Parent(s): 844f54f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -25
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
- try:
375
- # Read the content of the file
376
- with open(filename, 'rb') as file:
377
- file_content = file.read()
378
-
379
- # Generate QR code
380
- qr = qrcode.QRCode(
381
- version=1,
382
- error_correction=qrcode.constants.ERROR_CORRECT_L,
383
- box_size=10,
384
- border=4,
385
- )
386
- qr.add_data(file_content)
387
- qr.make(fit=True)
388
-
389
- img_qr = qr.make_image(fill_color="black", back_color="white")
390
-
391
- # Convert PIL Image to bytes for Gradio output
392
- img_byte_arr = io.BytesIO()
393
- img_qr.save(img_byte_arr, format='PNG')
394
- img_byte_arr = img_byte_arr.getvalue()
395
-
396
- return img_byte_arr
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