Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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.
|
174 |
-
|
175 |
if not realtime_update:
|
176 |
st.write("Double click to save crop")
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
#
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
|
190 |
-
|
191 |
-
#
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
|
196 |
-
button = st.
|
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.
|
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:
|