Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -130,7 +130,7 @@ if img_file:
|
|
130 |
if not realtime_update:
|
131 |
st.write("Double click to save crop")
|
132 |
|
133 |
-
col1, col2 = st.columns(
|
134 |
with col1:
|
135 |
st.subheader("Input: Upload and Crop Your Image")
|
136 |
# Get a cropped image from the frontend
|
@@ -148,38 +148,27 @@ if img_file:
|
|
148 |
# _ = cropped_img.thumbnail((150, 150))
|
149 |
st.image(cropped_img)
|
150 |
button = st.button("Run OCR")
|
|
|
|
|
151 |
if button:
|
152 |
with st.spinner('Running OCR...'):
|
153 |
if Lng == "Arabic":
|
154 |
ocr_text = predict_arabic(cropped_img)
|
155 |
-
st.subheader(f"OCR Results for {Lng}")
|
156 |
-
st.write(ocr_text)
|
157 |
-
text_file = BytesIO(ocr_text.encode())
|
158 |
-
st.download_button('Download Text', text_file, file_name='ocr_text.txt')
|
159 |
elif Lng == "English":
|
160 |
ocr_text = predict_nougat(cropped_img)
|
161 |
-
st.subheader(f"OCR Results for {Lng}")
|
162 |
-
st.write(ocr_text)
|
163 |
-
text_file = BytesIO(ocr_text.encode())
|
164 |
-
st.download_button('Download Text', text_file, file_name='ocr_text.txt')
|
165 |
elif Lng == "French":
|
166 |
ocr_text = predict_tesseract(cropped_img)
|
167 |
-
st.subheader(f"OCR Results for {Lng}")
|
168 |
-
st.write(ocr_text)
|
169 |
-
text_file = BytesIO(ocr_text.encode())
|
170 |
-
st.download_button('Download Text', text_file, file_name='ocr_text.txt')
|
171 |
elif Lng == "Korean":
|
172 |
ocr_text = predict_english(cropped_img)
|
173 |
-
st.subheader(f"OCR Results for {Lng}")
|
174 |
-
st.write(ocr_text)
|
175 |
-
text_file = BytesIO(ocr_text.encode())
|
176 |
-
st.download_button('Download Text', text_file, file_name='ocr_text.txt')
|
177 |
elif Lng == "Chinese":
|
178 |
ocr_text = predict_english(cropped_img)
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
183 |
|
184 |
|
185 |
|
|
|
130 |
if not realtime_update:
|
131 |
st.write("Double click to save crop")
|
132 |
|
133 |
+
col1, col2, col3 = st.columns(3)
|
134 |
with col1:
|
135 |
st.subheader("Input: Upload and Crop Your Image")
|
136 |
# Get a cropped image from the frontend
|
|
|
148 |
# _ = cropped_img.thumbnail((150, 150))
|
149 |
st.image(cropped_img)
|
150 |
button = st.button("Run OCR")
|
151 |
+
|
152 |
+
with col3:
|
153 |
if button:
|
154 |
with st.spinner('Running OCR...'):
|
155 |
if Lng == "Arabic":
|
156 |
ocr_text = predict_arabic(cropped_img)
|
|
|
|
|
|
|
|
|
157 |
elif Lng == "English":
|
158 |
ocr_text = predict_nougat(cropped_img)
|
|
|
|
|
|
|
|
|
159 |
elif Lng == "French":
|
160 |
ocr_text = predict_tesseract(cropped_img)
|
|
|
|
|
|
|
|
|
161 |
elif Lng == "Korean":
|
162 |
ocr_text = predict_english(cropped_img)
|
|
|
|
|
|
|
|
|
163 |
elif Lng == "Chinese":
|
164 |
ocr_text = predict_english(cropped_img)
|
165 |
+
|
166 |
+
st.subheader(f"OCR Results for {Lng}")
|
167 |
+
st.write(ocr_text)
|
168 |
+
text_file = BytesIO(ocr_text.encode())
|
169 |
+
st.download_button('Download Text', text_file, file_name='ocr_text.txt')
|
170 |
+
|
171 |
+
|
172 |
|
173 |
|
174 |
|