Update app.py
Browse files
app.py
CHANGED
|
@@ -2,27 +2,23 @@ import streamlit as st
|
|
| 2 |
from PIL import Image
|
| 3 |
import pytesseract
|
| 4 |
|
| 5 |
-
def tesseract_ocr(image,
|
| 6 |
with st.spinner("Performing OCR..."):
|
| 7 |
-
result = pytesseract.image_to_string(image, lang=
|
| 8 |
return result
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
st.title("AIconvert OCR")
|
| 15 |
st.markdown('<style>h1{color: #191970; text-align: center;}</style>', unsafe_allow_html=True)
|
| 16 |
|
| 17 |
image = st.file_uploader("Upload Image", type=["jpg", "png", "jpeg"])
|
| 18 |
-
languages =
|
|
|
|
| 19 |
|
| 20 |
if st.button("Submit"):
|
| 21 |
if image is not None:
|
| 22 |
image = Image.open(image)
|
| 23 |
-
result = tesseract_ocr(image,
|
| 24 |
st.subheader("Output:")
|
| 25 |
st.text(result)
|
| 26 |
else:
|
| 27 |
st.warning("Please upload an image.")
|
| 28 |
-
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
import pytesseract
|
| 4 |
|
| 5 |
+
def tesseract_ocr(image, language):
|
| 6 |
with st.spinner("Performing OCR..."):
|
| 7 |
+
result = pytesseract.image_to_string(image, lang=language)
|
| 8 |
return result
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
st.title("AIconvert OCR")
|
| 11 |
st.markdown('<style>h1{color: #191970; text-align: center;}</style>', unsafe_allow_html=True)
|
| 12 |
|
| 13 |
image = st.file_uploader("Upload Image", type=["jpg", "png", "jpeg"])
|
| 14 |
+
languages = pytesseract.get_languages()
|
| 15 |
+
selected_language = st.selectbox("Select Language", languages, index=0)
|
| 16 |
|
| 17 |
if st.button("Submit"):
|
| 18 |
if image is not None:
|
| 19 |
image = Image.open(image)
|
| 20 |
+
result = tesseract_ocr(image, selected_language)
|
| 21 |
st.subheader("Output:")
|
| 22 |
st.text(result)
|
| 23 |
else:
|
| 24 |
st.warning("Please upload an image.")
|
|
|