Update app.py
Browse files
app.py
CHANGED
@@ -105,10 +105,10 @@ def text_analyzer(my_text):
|
|
105 |
allData = [('"Token":{},\n"Lemma":{}'.format(token.text,token.lemma_))for token in docx ]
|
106 |
return allData
|
107 |
#@st.cache_resource(experimental_allow_widgets=True)
|
108 |
-
def load_models():
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
|
113 |
# Function For Extracting Entities
|
114 |
@st.experimental_singleton
|
@@ -167,14 +167,14 @@ def main():
|
|
167 |
# convert the image to black and white for better OCR
|
168 |
#ret,thresh1 = cv2.threshold(imge,120,255,cv2.THRESH_BINARY)
|
169 |
# pytesseract image to string to get results
|
170 |
-
text = str(pytesseract.image_to_string(img, config='--psm 6',lang="ben")) if st.checkbox("Bangla") else str(pytesseract.image_to_string(thresh1, config='--psm 6'))
|
171 |
-
|
172 |
st.success(text)
|
173 |
elif camera_photo:
|
174 |
img = Image.open(camera_photo)
|
175 |
img = img.save("img.png")
|
176 |
img = cv2.imread("img.png")
|
177 |
-
text = pytesseract.image_to_string(img
|
178 |
st.success(text)
|
179 |
elif uploaded_photo==None and camera_photo==None:
|
180 |
#our_image=load_image("image.jpg")
|
|
|
105 |
allData = [('"Token":{},\n"Lemma":{}'.format(token.text,token.lemma_))for token in docx ]
|
106 |
return allData
|
107 |
#@st.cache_resource(experimental_allow_widgets=True)
|
108 |
+
# def load_models():
|
109 |
+
# tokenizer = AutoTokenizer.from_pretrained('gpt2-large')
|
110 |
+
# model = GPT2LMHeadModel.from_pretrained('gpt2-large')
|
111 |
+
# return tokenizer, model
|
112 |
|
113 |
# Function For Extracting Entities
|
114 |
@st.experimental_singleton
|
|
|
167 |
# convert the image to black and white for better OCR
|
168 |
#ret,thresh1 = cv2.threshold(imge,120,255,cv2.THRESH_BINARY)
|
169 |
# pytesseract image to string to get results
|
170 |
+
#text = str(pytesseract.image_to_string(img, config='--psm 6',lang="ben")) if st.checkbox("Bangla") else str(pytesseract.image_to_string(thresh1, config='--psm 6'))
|
171 |
+
text = pytesseract.image_to_string(img) if st.checkbox("Mark to see English Image's Text") else pytesseract.image_to_string(img, lan="ben")
|
172 |
st.success(text)
|
173 |
elif camera_photo:
|
174 |
img = Image.open(camera_photo)
|
175 |
img = img.save("img.png")
|
176 |
img = cv2.imread("img.png")
|
177 |
+
text = pytesseract.image_to_string(img) if st.checkbox("Mark to see English Image's Text") else pytesseract.image_to_string(img, lan="ben")
|
178 |
st.success(text)
|
179 |
elif uploaded_photo==None and camera_photo==None:
|
180 |
#our_image=load_image("image.jpg")
|