gagan3012 commited on
Commit
fbb830e
·
1 Parent(s): 97cea74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -20
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, col3 = st.columns(3)
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
- with col3:
155
- if button:
156
- with st.spinner('Running OCR...'):
157
- if Lng == "Arabic":
158
- ocr_text = predict_arabic(cropped_img)
159
- elif Lng == "English":
160
- ocr_text = predict_nougat(cropped_img)
161
- elif Lng == "French":
162
- ocr_text = predict_tesseract(cropped_img)
163
- elif Lng == "Korean":
164
- ocr_text = predict_english(cropped_img)
165
- elif Lng == "Chinese":
166
- ocr_text = predict_english(cropped_img)
167
-
168
- st.subheader(f"OCR Results for {Lng}")
169
- st.write(ocr_text)
170
- text_file = BytesIO(ocr_text.encode())
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