Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -132,7 +132,7 @@ if img_file:
|
|
132 |
if not realtime_update:
|
133 |
st.write("Double click to save crop")
|
134 |
|
135 |
-
col1, col2
|
136 |
with col1:
|
137 |
st.subheader("Input: Upload and Crop Your Image")
|
138 |
# Get a cropped image from the frontend
|
@@ -151,24 +151,23 @@ if img_file:
|
|
151 |
st.image(cropped_img)
|
152 |
button = st.button("Run OCR")
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
st.download_button('Download Text', text_file, file_name='ocr_text.txt')
|
172 |
|
173 |
openai.api_key = ""
|
174 |
|
@@ -183,7 +182,7 @@ if img_file:
|
|
183 |
st.markdown(message["content"])
|
184 |
|
185 |
if prompt := st.chat_input("How can I help?"):
|
186 |
-
st.session_state.messages.append({"role": "user", "content": ocr_text+ prompt})
|
187 |
with st.chat_message("user"):
|
188 |
st.markdown(prompt)
|
189 |
|
|
|
132 |
if not realtime_update:
|
133 |
st.write("Double click to save crop")
|
134 |
|
135 |
+
col1, col2 = st.columns(2)
|
136 |
with col1:
|
137 |
st.subheader("Input: Upload and Crop Your Image")
|
138 |
# Get a cropped image from the frontend
|
|
|
151 |
st.image(cropped_img)
|
152 |
button = st.button("Run OCR")
|
153 |
|
154 |
+
if button:
|
155 |
+
with st.spinner('Running OCR...'):
|
156 |
+
if Lng == "Arabic":
|
157 |
+
ocr_text = predict_arabic(cropped_img)
|
158 |
+
elif Lng == "English":
|
159 |
+
ocr_text = predict_nougat(cropped_img)
|
160 |
+
elif Lng == "French":
|
161 |
+
ocr_text = predict_tesseract(cropped_img)
|
162 |
+
elif Lng == "Korean":
|
163 |
+
ocr_text = predict_english(cropped_img)
|
164 |
+
elif Lng == "Chinese":
|
165 |
+
ocr_text = predict_english(cropped_img)
|
166 |
+
|
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 |
|
172 |
openai.api_key = ""
|
173 |
|
|
|
182 |
st.markdown(message["content"])
|
183 |
|
184 |
if prompt := st.chat_input("How can I help?"):
|
185 |
+
st.session_state.messages.append({"role": "user", "content": ocr_text + prompt})
|
186 |
with st.chat_message("user"):
|
187 |
st.markdown(prompt)
|
188 |
|