Spaces:
Runtime error
Runtime error
feat: column separation
Browse files
app.py
CHANGED
@@ -71,7 +71,11 @@ with st.sidebar:
|
|
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 |
|
76 |
st.text(f'baking the 🍩s...')
|
77 |
|
@@ -97,20 +101,21 @@ else:
|
|
97 |
|
98 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
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 |
+
st.image(image, caption='Your target receipt')
|
79 |
|
80 |
st.text(f'baking the 🍩s...')
|
81 |
|
|
|
101 |
|
102 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
103 |
|
104 |
+
with col2:
|
105 |
+
if information == 'Extract all!':
|
106 |
+
st.text(f'parsing 🧾 (extracting all)...')
|
107 |
+
pretrained_model, processor, task_prompt = pretrained_model_a, processor_a, f"<s>"
|
108 |
+
pretrained_model.to(device)
|
109 |
+
parsed_receipt_info_a, _ = run_prediction(image)
|
110 |
+
pretrained_model, processor, task_prompt = pretrained_model_b, processor_b, f"<s_cord-v2>"
|
111 |
+
pretrained_model.to(device)
|
112 |
+
parsed_receipt_info_b, _ = run_prediction(image)
|
113 |
+
st.text(f'\nReceipt Summary:')
|
114 |
+
st.json(parsed_receipt_info_a)
|
115 |
+
st.text(f'\nReceipt Menu Details:')
|
116 |
+
st.json(parsed_receipt_info_b)
|
117 |
+
else:
|
118 |
+
st.text(f'parsing 🧾...')
|
119 |
+
parsed_receipt_info, _ = run_prediction(image)
|
120 |
+
st.text(f'\n{information}')
|
121 |
+
st.json(parsed_receipt_info)
|