Pash1986 commited on
Commit
9885b48
1 Parent(s): 453e0c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -2
app.py CHANGED
@@ -21,6 +21,7 @@ from reportlab.lib.pagesizes import letter
21
  from reportlab.lib.utils import ImageReader
22
  import boto3
23
  import re
 
24
 
25
  output_parser = StrOutputParser()
26
 
@@ -242,7 +243,7 @@ def record_participant(email, company, description, images):
242
  participants_db.insert_one(participant_data)
243
 
244
  # Create PDF after recording participant
245
- pdf_file = create_pdf(images, description, email, company)
246
  return pdf_file
247
 
248
  def create_pdf(images, description, email, company):
@@ -369,6 +370,26 @@ def start_image_search(image, text):
369
  description = generate_image_description_with_claude(images_base64_strs, img_base64_str)
370
  return images, description
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
 
373
  with gr.Blocks() as demo:
374
 
@@ -406,11 +427,22 @@ with gr.Blocks() as demo:
406
  outputs=[output_gallery, output_description]
407
  )
408
 
 
 
409
  record_button.click(
410
  fn=record_participant,
411
  inputs=[email_input, company_input, output_description, output_gallery],
412
- outputs=gr.File(label="Download Search Results as PDF")
413
  )
 
 
 
 
 
 
 
 
 
414
  with gr.Tab("Code"):
415
  gr.Code(label="Code", language="python", value=fetch_url_data('https://huggingface.co/spaces/MongoDB/aws-bedrock-celeb-matcher/raw/main/app.py'))
416
 
 
21
  from reportlab.lib.utils import ImageReader
22
  import boto3
23
  import re
24
+ import qrcode
25
 
26
  output_parser = StrOutputParser()
27
 
 
243
  participants_db.insert_one(participant_data)
244
 
245
  # Create PDF after recording participant
246
+ qr_image = create_pdf(images, description, email, company)
247
  return pdf_file
248
 
249
  def create_pdf(images, description, email, company):
 
370
  description = generate_image_description_with_claude(images_base64_strs, img_base64_str)
371
  return images, description
372
 
373
+ def generate_qr_code(url):
374
+ # Generate QR code
375
+ qr = qrcode.QRCode(
376
+ version=1,
377
+ error_correction=qrcode.constants.ERROR_CORRECT_L,
378
+ box_size=10,
379
+ border=4,
380
+ )
381
+ qr.add_data(url)
382
+ qr.make(fit=True)
383
+
384
+ img_qr = qr.make_image(fill_color="black", back_color="white")
385
+
386
+ # Convert PIL Image to bytes for displaying or saving
387
+ img_byte_arr = io.BytesIO()
388
+ img_qr.save(img_byte_arr, format='PNG')
389
+ img_byte_arr = img_byte_arr.getvalue()
390
+
391
+ return img_byte_arr
392
+
393
 
394
  with gr.Blocks() as demo:
395
 
 
427
  outputs=[output_gallery, output_description]
428
  )
429
 
430
+ pdf_file=gr.File(label="Download Search Results as PDF")
431
+
432
  record_button.click(
433
  fn=record_participant,
434
  inputs=[email_input, company_input, output_description, output_gallery],
435
+ outputs=pdf_file
436
  )
437
+
438
+ gr.Interface(
439
+ generate_qr_code,
440
+ inputs=pdf_file
441
+ outputs=gr.outputs.Image(type="numpy", label="Generated QR Code"),
442
+ title="Filename to QR Code Generator",
443
+ description="Enter the filename to generate its QR code"
444
+ )
445
+
446
  with gr.Tab("Code"):
447
  gr.Code(label="Code", language="python", value=fetch_url_data('https://huggingface.co/spaces/MongoDB/aws-bedrock-celeb-matcher/raw/main/app.py'))
448