laverdes commited on
Commit
af15a96
·
1 Parent(s): 0efa4b1

chore: style refactor

Browse files
Files changed (1) hide show
  1. app.py +30 -32
app.py CHANGED
@@ -93,40 +93,38 @@ st.text(f'{information} mode is ON!\nTarget 🧾: {receipt}') # \n(opening imag
93
 
94
  col1, col2 = st.columns(2)
95
 
96
- with st.spinner('Loading image...'):
97
- if photo:
98
- image = photo
99
- st.info("photo loaded to image")
100
- elif image_upload:
101
- image = image_upload
102
- else:
103
- image = Image.open(f"./img/receipt-{receipt}.jpg")
104
- with col1:
105
- st.image(image, caption='Your target receipt')
106
-
107
- st.info(f'baking the 🍩s...')
108
-
109
- if information == 'Receipt Summary':
110
- processor = DonutProcessor.from_pretrained("unstructuredio/donut-base-sroie")
111
- pretrained_model = VisionEncoderDecoderModel.from_pretrained("unstructuredio/donut-base-sroie")
112
- task_prompt = f"<s>"
113
- device = "cuda" if torch.cuda.is_available() else "cpu"
114
- pretrained_model.to(device)
115
-
116
- elif information == 'Receipt Menu Details':
117
- processor = DonutProcessor.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
118
- pretrained_model = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
119
- task_prompt = f"<s_cord-v2>"
120
- device = "cuda" if torch.cuda.is_available() else "cpu"
121
- pretrained_model.to(device)
122
-
123
  else:
124
- processor_a = DonutProcessor.from_pretrained("unstructuredio/donut-base-sroie")
125
- processor_b = DonutProcessor.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
126
- pretrained_model_a = VisionEncoderDecoderModel.from_pretrained("unstructuredio/donut-base-sroie")
127
- pretrained_model_b = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
 
 
 
 
 
 
 
128
 
129
- device = "cuda" if torch.cuda.is_available() else "cpu"
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  with col2:
132
  if information == 'Extract all':
 
93
 
94
  col1, col2 = st.columns(2)
95
 
96
+ if photo:
97
+ image = photo
98
+ st.info("photo loaded to image")
99
+ elif image_upload:
100
+ image = image_upload
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  else:
102
+ image = Image.open(f"./img/receipt-{receipt}.jpg")
103
+ with col1:
104
+ st.image(image, caption='Your target receipt')
105
+
106
+ with st.spinner(f'baking the 🍩s...'):
107
+ if information == 'Receipt Summary':
108
+ processor = DonutProcessor.from_pretrained("unstructuredio/donut-base-sroie")
109
+ pretrained_model = VisionEncoderDecoderModel.from_pretrained("unstructuredio/donut-base-sroie")
110
+ task_prompt = f"<s>"
111
+ device = "cuda" if torch.cuda.is_available() else "cpu"
112
+ pretrained_model.to(device)
113
 
114
+ elif information == 'Receipt Menu Details':
115
+ processor = DonutProcessor.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
116
+ pretrained_model = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
117
+ task_prompt = f"<s_cord-v2>"
118
+ device = "cuda" if torch.cuda.is_available() else "cpu"
119
+ pretrained_model.to(device)
120
+
121
+ else:
122
+ processor_a = DonutProcessor.from_pretrained("unstructuredio/donut-base-sroie")
123
+ processor_b = DonutProcessor.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
124
+ pretrained_model_a = VisionEncoderDecoderModel.from_pretrained("unstructuredio/donut-base-sroie")
125
+ pretrained_model_b = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base-finetuned-cord-v2")
126
+
127
+ device = "cuda" if torch.cuda.is_available() else "cpu"
128
 
129
  with col2:
130
  if information == 'Extract all':