gagan3012 commited on
Commit
6d28407
·
1 Parent(s): 995d7f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -170,30 +170,30 @@ Models = {
170
  st.sidebar.markdown(f"### Selected Model: {Models[Lng]}")
171
 
172
  if img_file:
173
- if not img_file.name.endswith(".pdf"):
174
- cropped_img = Image.open(img_file)
175
  if not realtime_update:
176
  st.write("Double click to save crop")
177
 
178
- # col1, col2 = st.columns(2)
179
- # with col1:
180
- # st.subheader("Input: Upload and Crop Your Image")
181
- # # Get a cropped image from the frontend
182
- # cropped_img = st_cropper(
183
- # img,
184
- # realtime_update=realtime_update,
185
- # box_color="#FF0000",
186
- # aspect_ratio=aspect_ratio,
187
- # should_resize_image=True,
188
- # )
189
 
190
- # with col2:
191
- # # Manipulate cropped image at will
192
- # st.subheader("Output: Preview and Analyze")
193
- # # _ = cropped_img.thumbnail((150, 150))
194
- # st.image(cropped_img)
195
 
196
- button = st.sidebar.button("Run OCR")
197
 
198
  if button:
199
  with st.spinner('Running OCR...'):
@@ -214,7 +214,7 @@ if img_file:
214
  st.download_button('Download Text', text_file,
215
  file_name='ocr_text.txt')
216
 
217
- elif img_file.name.endswith(".pdf"):
218
  button = st.sidebar.button("Run OCR")
219
 
220
  if button:
 
170
  st.sidebar.markdown(f"### Selected Model: {Models[Lng]}")
171
 
172
  if img_file:
173
+ if not img_file.type == ".pdf":
174
+ img = Image.open(img_file)
175
  if not realtime_update:
176
  st.write("Double click to save crop")
177
 
178
+ col1, col2 = st.columns(2)
179
+ with col1:
180
+ st.subheader("Input: Upload and Crop Your Image")
181
+ # Get a cropped image from the frontend
182
+ cropped_img = st_cropper(
183
+ img,
184
+ realtime_update=realtime_update,
185
+ box_color="#FF0000",
186
+ aspect_ratio=aspect_ratio,
187
+ should_resize_image=True,
188
+ )
189
 
190
+ with col2:
191
+ # Manipulate cropped image at will
192
+ st.subheader("Output: Preview and Analyze")
193
+ # _ = cropped_img.thumbnail((150, 150))
194
+ st.image(cropped_img)
195
 
196
+ button = st.button("Run OCR")
197
 
198
  if button:
199
  with st.spinner('Running OCR...'):
 
214
  st.download_button('Download Text', text_file,
215
  file_name='ocr_text.txt')
216
 
217
+ elif img_file.type == ".pdf":
218
  button = st.sidebar.button("Run OCR")
219
 
220
  if button: