Update app.py
Browse files
app.py
CHANGED
|
@@ -101,14 +101,14 @@ def main():
|
|
| 101 |
message = st.text_input("Type your text here!")
|
| 102 |
camera_photo = st.camera_input("Take a photo, Containing English or Bangla texts", on_change=change_photo_state)
|
| 103 |
uploaded_photo = st.file_uploader("Upload Image, Containing English or Bangla texts",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
if st.session_state["photo"]=="done" or message
|
| 107 |
if st.button("Process_PDF"):
|
| 108 |
text = read_pdf(uploaded_photo)
|
| 109 |
-
|
| 110 |
st.success(text)
|
| 111 |
-
|
| 112 |
img = Image.open(uploaded_photo)
|
| 113 |
img = img.save("img.png")
|
| 114 |
img = cv2.imread("img.png")
|
|
@@ -124,7 +124,6 @@ def main():
|
|
| 124 |
#our_image=load_image("image.jpg")
|
| 125 |
#img = cv2.imread("scholarly_text.jpg")
|
| 126 |
text = message
|
| 127 |
-
if st.checkbox("Show)
|
| 128 |
if st.checkbox("Show Named Entities English/Bangla"):
|
| 129 |
entity_result = entity_analyzer(text)
|
| 130 |
st.json(entity_result)
|
|
|
|
| 101 |
message = st.text_input("Type your text here!")
|
| 102 |
camera_photo = st.camera_input("Take a photo, Containing English or Bangla texts", on_change=change_photo_state)
|
| 103 |
uploaded_photo = st.file_uploader("Upload Image, Containing English or Bangla texts",type=['jpg','png','jpeg','pdf'], on_change=change_photo_state)
|
| 104 |
+
if "photo" not in st.session_state:
|
| 105 |
+
st.session_state["photo"]="not done"
|
| 106 |
+
if st.session_state["photo"]=="done" or message:
|
| 107 |
if st.button("Process_PDF"):
|
| 108 |
text = read_pdf(uploaded_photo)
|
| 109 |
+
#text = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
|
| 110 |
st.success(text)
|
| 111 |
+
elif uploaded_photo and uploaded_photo.type != "application/pdf":
|
| 112 |
img = Image.open(uploaded_photo)
|
| 113 |
img = img.save("img.png")
|
| 114 |
img = cv2.imread("img.png")
|
|
|
|
| 124 |
#our_image=load_image("image.jpg")
|
| 125 |
#img = cv2.imread("scholarly_text.jpg")
|
| 126 |
text = message
|
|
|
|
| 127 |
if st.checkbox("Show Named Entities English/Bangla"):
|
| 128 |
entity_result = entity_analyzer(text)
|
| 129 |
st.json(entity_result)
|