Spaces:
Runtime error
Runtime error
feat: functionality to upload a local receipt
Browse files
app.py
CHANGED
|
@@ -59,23 +59,27 @@ with st.sidebar:
|
|
| 59 |
information = st.radio(
|
| 60 |
"What information inside the are you interested in?",
|
| 61 |
('Receipt Summary', 'Receipt Menu Details', 'Extract all!'))
|
| 62 |
-
receipt = st.selectbox('Pick one 🧾', ['1', '2', '3', '4', '5', '6'], index=
|
| 63 |
|
| 64 |
# file upload
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
| 69 |
# st.write(bytes_data)
|
| 70 |
|
| 71 |
-
st.text(f'{information} mode is ON!\nTarget 🧾: {receipt}\n(opening image @:./img/receipt-{receipt}.png)')
|
| 72 |
|
| 73 |
image = Image.open(f"./img/receipt-{receipt}.jpg")
|
| 74 |
|
| 75 |
col1, col2 = st.columns(2)
|
| 76 |
|
| 77 |
with col1:
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
st.text(f'baking the 🍩s...')
|
| 81 |
|
|
|
|
| 59 |
information = st.radio(
|
| 60 |
"What information inside the are you interested in?",
|
| 61 |
('Receipt Summary', 'Receipt Menu Details', 'Extract all!'))
|
| 62 |
+
receipt = st.selectbox('Pick one 🧾', ['1', '2', '3', '4', '5', '6'], index=3)
|
| 63 |
|
| 64 |
# file upload
|
| 65 |
+
uploaded_file = st.file_uploader("Upload a 🧾")
|
| 66 |
+
if uploaded_file is not None:
|
| 67 |
+
# To read file as bytes:
|
| 68 |
+
image_bytes_data = uploaded_file.getvalue()
|
| 69 |
+
image_upload = Image.frombytes('RGBA', (128,128), image_bytes_data, 'raw')
|
| 70 |
# st.write(bytes_data)
|
| 71 |
|
| 72 |
+
st.text(f'{information} mode is ON!\nTarget 🧾: {receipt}') # \n(opening image @:./img/receipt-{receipt}.png)')
|
| 73 |
|
| 74 |
image = Image.open(f"./img/receipt-{receipt}.jpg")
|
| 75 |
|
| 76 |
col1, col2 = st.columns(2)
|
| 77 |
|
| 78 |
with col1:
|
| 79 |
+
if image_upload:
|
| 80 |
+
st.image(image_upload, caption='Your target receipt')
|
| 81 |
+
else:
|
| 82 |
+
st.image(image, caption='Your target receipt')
|
| 83 |
|
| 84 |
st.text(f'baking the 🍩s...')
|
| 85 |
|