Update app.py
Browse files
app.py
CHANGED
|
@@ -81,8 +81,9 @@ st.markdown("## Persian and Arabic OCR :")
|
|
| 81 |
|
| 82 |
|
| 83 |
def main():
|
|
|
|
| 84 |
# upload image file
|
| 85 |
-
file =
|
| 86 |
# global try_again
|
| 87 |
# if try_again == 1:
|
| 88 |
# del st.session_state['controllo']
|
|
@@ -92,7 +93,8 @@ def main():
|
|
| 92 |
if file is not None:
|
| 93 |
image = Image.open(file) # read image with PIL library
|
| 94 |
st.image(image) #display
|
| 95 |
-
|
|
|
|
| 96 |
# it will only detect the English and Turkish part of the image as text
|
| 97 |
reader = easyocr.Reader(['fa','ar'], gpu=False) #, model_storage_directory='temp/',user_network_directory='temp/net'
|
| 98 |
result = reader.readtext(np.array(image)) # turn image to numpy array
|
|
|
|
| 81 |
|
| 82 |
|
| 83 |
def main():
|
| 84 |
+
holder = st.empty()
|
| 85 |
# upload image file
|
| 86 |
+
file = holder.file_uploader(label = "Upload Here", type=['png', 'jpg', 'jpeg'])
|
| 87 |
# global try_again
|
| 88 |
# if try_again == 1:
|
| 89 |
# del st.session_state['controllo']
|
|
|
|
| 93 |
if file is not None:
|
| 94 |
image = Image.open(file) # read image with PIL library
|
| 95 |
st.image(image) #display
|
| 96 |
+
holder.empty()
|
| 97 |
+
|
| 98 |
# it will only detect the English and Turkish part of the image as text
|
| 99 |
reader = easyocr.Reader(['fa','ar'], gpu=False) #, model_storage_directory='temp/',user_network_directory='temp/net'
|
| 100 |
result = reader.readtext(np.array(image)) # turn image to numpy array
|