Severian commited on
Commit
8845f6c
·
verified ·
1 Parent(s): 19745bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -111,7 +111,9 @@ def scan_qr_code(image):
111
  return None
112
 
113
  def invert_image(image):
114
- return ImageOps.invert(image)
 
 
115
 
116
  @spaces.GPU()
117
  def inference(
@@ -382,7 +384,9 @@ with gr.Blocks(theme='Hev832/Applio') as blocks:
382
 
383
  with gr.Column():
384
  result_image = gr.Image(label="Your Artistic QR Code")
385
- scan_button = gr.Button("Scan QR Code")
 
 
386
  scan_result = gr.Textbox(label="Scan Result", interactive=False)
387
 
388
  gr.Markdown(
@@ -408,13 +412,23 @@ with gr.Blocks(theme='Hev832/Applio') as blocks:
408
  else:
409
  return "Failed to scan QR code. Try adjusting the settings for better visibility."
410
 
 
 
 
 
 
411
  scan_button.click(
412
  scan_and_display,
413
  inputs=[result_image],
414
  outputs=[scan_result]
415
  )
416
 
417
-
 
 
 
 
 
418
  run_btn.click(
419
  inference,
420
  inputs=[
 
111
  return None
112
 
113
  def invert_image(image):
114
+ if image is None:
115
+ return None
116
+ return ImageOps.invert(image.convert('RGB'))
117
 
118
  @spaces.GPU()
119
  def inference(
 
384
 
385
  with gr.Column():
386
  result_image = gr.Image(label="Your Artistic QR Code")
387
+ with gr.Row():
388
+ scan_button = gr.Button("Scan QR Code")
389
+ invert_button = gr.Button("Invert Image")
390
  scan_result = gr.Textbox(label="Scan Result", interactive=False)
391
 
392
  gr.Markdown(
 
412
  else:
413
  return "Failed to scan QR code. Try adjusting the settings for better visibility."
414
 
415
+ def invert_displayed_image(image):
416
+ if image is None:
417
+ return None
418
+ return invert_image(image)
419
+
420
  scan_button.click(
421
  scan_and_display,
422
  inputs=[result_image],
423
  outputs=[scan_result]
424
  )
425
 
426
+ invert_button.click(
427
+ invert_displayed_image,
428
+ inputs=[result_image],
429
+ outputs=[result_image]
430
+ )
431
+
432
  run_btn.click(
433
  inference,
434
  inputs=[