Spaces:
Runtime error
Runtime error
feat: camera input is now available on sidebar
Browse files
app.py
CHANGED
@@ -64,6 +64,7 @@ Come and join us in our public repos and contribute! Each of your contributions
|
|
64 |
''')
|
65 |
|
66 |
image_upload = None
|
|
|
67 |
with st.sidebar:
|
68 |
information = st.radio(
|
69 |
"What information inside the 🧾s are you interested in extracting?",
|
@@ -78,9 +79,20 @@ with st.sidebar:
|
|
78 |
image_upload = Image.open(BytesIO(image_bytes_data)) #.frombytes('RGBA', (128,128), image_bytes_data, 'raw')
|
79 |
# st.write(bytes_data)
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
st.text(f'{information} mode is ON!\nTarget 🧾: {receipt}') # \n(opening image @:./img/receipt-{receipt}.png)')
|
82 |
|
83 |
-
if
|
|
|
|
|
84 |
image = image_upload
|
85 |
else:
|
86 |
image = Image.open(f"./img/receipt-{receipt}.jpg")
|
|
|
64 |
''')
|
65 |
|
66 |
image_upload = None
|
67 |
+
photo = None
|
68 |
with st.sidebar:
|
69 |
information = st.radio(
|
70 |
"What information inside the 🧾s are you interested in extracting?",
|
|
|
79 |
image_upload = Image.open(BytesIO(image_bytes_data)) #.frombytes('RGBA', (128,128), image_bytes_data, 'raw')
|
80 |
# st.write(bytes_data)
|
81 |
|
82 |
+
camera_click = st.button('Use my camera')
|
83 |
+
|
84 |
+
if camera_click:
|
85 |
+
img_file_buffer = st.camera_input("Take a picture of your receipt!")
|
86 |
+
|
87 |
+
if img_file_buffer is not None:
|
88 |
+
# To read image file buffer as a PIL Image:
|
89 |
+
photo = Image.open(img_file_buffer)
|
90 |
+
|
91 |
st.text(f'{information} mode is ON!\nTarget 🧾: {receipt}') # \n(opening image @:./img/receipt-{receipt}.png)')
|
92 |
|
93 |
+
if photo:
|
94 |
+
image = photo
|
95 |
+
elif image_upload:
|
96 |
image = image_upload
|
97 |
else:
|
98 |
image = Image.open(f"./img/receipt-{receipt}.jpg")
|