Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ def decode(im,col):
|
|
| 8 |
img = cv2.imread(f'{im}')
|
| 9 |
try:
|
| 10 |
results = zxingcpp.read_barcodes(img)
|
| 11 |
-
return results[0].text
|
| 12 |
except Exception:
|
| 13 |
|
| 14 |
#qr_img=Image.open(im).convert("RGBA")
|
|
@@ -29,9 +29,9 @@ def decode(im,col):
|
|
| 29 |
try:
|
| 30 |
results = zxingcpp.read_barcodes(img)
|
| 31 |
print (results[0].text)
|
| 32 |
-
return results[0].text
|
| 33 |
except Exception:
|
| 34 |
-
return "QR Code not Detected \nTry choosing the QR code color using the eyedropper in the Color Picker"
|
| 35 |
|
| 36 |
|
| 37 |
|
|
@@ -39,10 +39,11 @@ with gr.Blocks() as app:
|
|
| 39 |
with gr.Row():
|
| 40 |
with gr.Column():
|
| 41 |
in_im = gr.Image(label="QR Image to Decode",type='filepath')
|
|
|
|
| 42 |
with gr.Column():
|
| 43 |
choose_color = gr.ColorPicker(label="Choose QR color (eyedropper)")
|
| 44 |
dec_btn = gr.Button("Decode QR")
|
| 45 |
text_out = gr.Textbox(label="Decoded Text")
|
| 46 |
|
| 47 |
-
dec_btn.click(decode,[in_im,choose_color],text_out)
|
| 48 |
app.queue(concurrency_count=10).launch()
|
|
|
|
| 8 |
img = cv2.imread(f'{im}')
|
| 9 |
try:
|
| 10 |
results = zxingcpp.read_barcodes(img)
|
| 11 |
+
return results[0].text,None
|
| 12 |
except Exception:
|
| 13 |
|
| 14 |
#qr_img=Image.open(im).convert("RGBA")
|
|
|
|
| 29 |
try:
|
| 30 |
results = zxingcpp.read_barcodes(img)
|
| 31 |
print (results[0].text)
|
| 32 |
+
return results[0].text,'conv_im.png'
|
| 33 |
except Exception:
|
| 34 |
+
return "QR Code not Detected \nTry choosing the QR code color using the eyedropper in the Color Picker",'conv_im.png'
|
| 35 |
|
| 36 |
|
| 37 |
|
|
|
|
| 39 |
with gr.Row():
|
| 40 |
with gr.Column():
|
| 41 |
in_im = gr.Image(label="QR Image to Decode",type='filepath')
|
| 42 |
+
out_im = gr.Image(type='filepath')
|
| 43 |
with gr.Column():
|
| 44 |
choose_color = gr.ColorPicker(label="Choose QR color (eyedropper)")
|
| 45 |
dec_btn = gr.Button("Decode QR")
|
| 46 |
text_out = gr.Textbox(label="Decoded Text")
|
| 47 |
|
| 48 |
+
dec_btn.click(decode,[in_im,choose_color],[text_out,out_im])
|
| 49 |
app.queue(concurrency_count=10).launch()
|